linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] serial: imx: fix a possible NULL dereference
@ 2015-11-24 14:36 LABBE Corentin
  2015-11-24 14:36 ` [PATCH v2 1/1] " LABBE Corentin
  0 siblings, 1 reply; 3+ messages in thread
From: LABBE Corentin @ 2015-11-24 14:36 UTC (permalink / raw)
  To: gregkh, jslaby; +Cc: LABBE Corentin, linux-kernel, linux-serial

Hello

Changes since v1
- Use of_device_get_match_data as suggested by Uwe Kleine-Konig

LABBE Corentin (2):
  serial: imx: fix a possible NULL dereference
  serial: imx: constify imx_uart_data structures

 drivers/tty/serial/imx.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

-- 
2.4.10

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

* [PATCH v2 1/1] serial: imx: fix a possible NULL dereference
  2015-11-24 14:36 [PATCH v2 0/1] serial: imx: fix a possible NULL dereference LABBE Corentin
@ 2015-11-24 14:36 ` LABBE Corentin
  2015-11-29 17:03   ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: LABBE Corentin @ 2015-11-24 14:36 UTC (permalink / raw)
  To: gregkh, jslaby; +Cc: LABBE Corentin, linux-kernel, linux-serial

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

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

* Re: [PATCH v2 1/1] serial: imx: fix a possible NULL dereference
  2015-11-24 14:36 ` [PATCH v2 1/1] " LABBE Corentin
@ 2015-11-29 17:03   ` Uwe Kleine-König
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2015-11-29 17:03 UTC (permalink / raw)
  To: LABBE Corentin; +Cc: gregkh, jslaby, linux-kernel, linux-serial

On Tue, Nov 24, 2015 at 03:36:57PM +0100, LABBE Corentin wrote:
> 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>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2015-11-29 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 14:36 [PATCH v2 0/1] serial: imx: fix a possible NULL dereference LABBE Corentin
2015-11-24 14:36 ` [PATCH v2 1/1] " LABBE Corentin
2015-11-29 17:03   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).