diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2018-02-23 14:38:30 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-02-28 15:29:59 +0100 |
commit | ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47 (patch) | |
tree | b87672bd402ff677c63b8f4f046234d8a8fc1551 /drivers/tty | |
parent | serial: arc_uart: Fix out-of-bounds access through DT alias (diff) | |
download | linux-ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47.tar.xz linux-ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47.zip |
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: c9e2e946fb0ba5d2 ("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>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/fsl_lpuart.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 8cf112f2efc3..51e47a63d61a 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -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); |