mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 10:04:12 +08:00
serial: fsl_lpuart: Fix out-of-bounds access through DT alias
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f9f5786987
commit
ffab87fdec
@ -2145,6 +2145,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;
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
sport->port.membase = devm_ioremap_resource(&pdev->dev, res);
|
||||
|
Loading…
Reference in New Issue
Block a user