public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: serial: Add a NULL check for of_node
@ 2024-08-14 10:15 Ma Ke
  2024-08-14 10:28 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-08-14 10:15 UTC (permalink / raw)
  To: gregkh, jirislaby, make24, u.kleine-koenig, tglx, zhang_shurong,
	B56683, cosmin.stoica, stefan-gabriel.mirea, Larisa.Grigore,
	matthew.nunez
  Cc: linux-kernel, linux-serial, stable

The pdev->dev.of_node can be NULL if the "serial" node is absent.
Add a NULL check for np to return an error in such cases.

Found by code review. Compile tested only.

Cc: stable@vger.kernel.org
Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/tty/serial/fsl_linflexuart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
index e972df4b188d..f46f3c21ee1b 100644
--- a/drivers/tty/serial/fsl_linflexuart.c
+++ b/drivers/tty/serial/fsl_linflexuart.c
@@ -811,6 +811,9 @@ static int linflex_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
+	if (!np)
+		return -ENODEV;
+
 	sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
 	if (!sport)
 		return -ENOMEM;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-14 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14 10:15 [PATCH] tty: serial: Add a NULL check for of_node Ma Ke
2024-08-14 10:28 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox