[PATCH] tty: serial: Add a NULL check for of_node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>
---
 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





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux