Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276519

[PATCH v2 1/1] serial: imx: fix a possible NULL dereference

From LABBE Corentin <clabbe.montjoie@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/1] serial: imx: fix a possible NULL dereference
Date 2015-11-24 15:40 +0100
Message-ID <qymVb-Ro-19@gated-at.bofh.it> (permalink)
References <qymVb-Ro-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


of_match_device could return NULL, and so cause a NULL pointer
dereference later.
Even if the probability of this case is very low, fixing it made
static analyzers happy.
Solving this with of_device_get_match_data made also code simplier.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/tty/serial/imx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 016e4be..76818f5 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1857,11 +1857,10 @@ static int serial_imx_probe_dt(struct imx_port *sport,
 		struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	const struct of_device_id *of_id =
-			of_match_device(imx_uart_dt_ids, &pdev->dev);
 	int ret;
 
-	if (!np)
+	sport->devdata = of_device_get_match_data(&pdev->dev);
+	if (!sport->devdata)
 		/* no device tree device */
 		return 1;
 
@@ -1878,8 +1877,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
 	if (of_get_property(np, "fsl,dte-mode", NULL))
 		sport->dte_mode = 1;
 
-	sport->devdata = of_id->data;
-
 	return 0;
 }
 #else
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/1] serial: imx: fix a possible NULL dereference LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-11-24 15:40 +0100
  Re: [PATCH v2 1/1] serial: imx: fix a possible NULL dereference Uwe Kleine-König   <u.kleine-koenig@pengutronix.de> - 2015-11-29 18:10 +0100

csiph-web