mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
serial: fsl_lpuart: Fix out-of-bounds access through DT alias
[ Upstream commitffab87fdec] 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:c9e2e946fb("tty: serial: add Freescale lpuart driver support") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
25c1996897
commit
f213d3f91f
|
|
@ -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);
|
||||
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->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user