lkml.org 
[lkml]   [2022]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] tty: serial: samsung_tty: Check null pointer after calling of_match_node
Date
If there is no suitable node, of_match_node() will return NULL pointer.
Therefore it should be better to check it in order to avoid the
dereference of NULL pointer.
And the only caller s3c24xx_serial_probe() has already checked the
return value of the s3c24xx_get_driver_data().
So the new check can be dealed with.

Fixes: 55ed51fff224 ("{tty: serial, nand: onenand}: samsung: rename to fix build warning")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/tty/serial/samsung_tty.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index e2f49863e9c2..efbf9a7d5e92 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2185,6 +2185,9 @@ s3c24xx_get_driver_data(struct platform_device *pdev)
const struct of_device_id *match;

match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
+ if (!match)
+ return NULL;
+
return (struct s3c24xx_serial_drv_data *)match->data;
}
#endif
--
2.25.1
\
 
 \ /
  Last update: 2022-01-11 09:18    [W:0.045 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site