Skip to content

Commit 5f8b904

Browse files
montjoiegregkh
authored andcommitted
serial: imx: fix a possible NULL dereference
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4d2ae60 commit 5f8b904

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/tty/serial/imx.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,11 +1857,10 @@ static int serial_imx_probe_dt(struct imx_port *sport,
18571857
struct platform_device *pdev)
18581858
{
18591859
struct device_node *np = pdev->dev.of_node;
1860-
const struct of_device_id *of_id =
1861-
of_match_device(imx_uart_dt_ids, &pdev->dev);
18621860
int ret;
18631861

1864-
if (!np)
1862+
sport->devdata = of_device_get_match_data(&pdev->dev);
1863+
if (!sport->devdata)
18651864
/* no device tree device */
18661865
return 1;
18671866

@@ -1878,8 +1877,6 @@ static int serial_imx_probe_dt(struct imx_port *sport,
18781877
if (of_get_property(np, "fsl,dte-mode", NULL))
18791878
sport->dte_mode = 1;
18801879

1881-
sport->devdata = of_id->data;
1882-
18831880
return 0;
18841881
}
18851882
#else

0 commit comments

Comments
 (0)