Commit f213d3f9 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Greg Kroah-Hartman

serial: fsl_lpuart: Fix out-of-bounds access through DT alias

[ Upstream commit ffab87fd ]

The lpuart_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: c9e2e946 ("tty: serial: add Freescale lpuart driver support")
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 25c19968
...@@ -1818,6 +1818,10 @@ static int lpuart_probe(struct platform_device *pdev) ...@@ -1818,6 +1818,10 @@ static int lpuart_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
return ret; return ret;
} }
if (ret >= ARRAY_SIZE(lpuart_ports)) {
dev_err(&pdev->dev, "serial%d out of range\n", ret);
return -EINVAL;
}
sport->port.line = ret; sport->port.line = ret;
sport->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart"); sport->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment