summaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2018-02-23 14:38:30 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-28 15:29:59 +0100
commitffab87fdecc655cc676f8be8dd1a2c5e22bd6d47 (patch)
treeb87672bd402ff677c63b8f4f046234d8a8fc1551 /drivers/tty
parentf9f5786987e81d166c60833edcb7d1836aa16944 (diff)
downloadblackbird-op-linux-ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47.tar.gz
blackbird-op-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.c4
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);
OpenPOWER on IntegriCloud