]>
Commit | Line | Data |
---|---|---|
06e23a17 GKH |
1 | From foo@baz Thu May 24 11:09:34 CEST 2018 |
2 | From: Geert Uytterhoeven <geert+renesas@glider.be> | |
3 | Date: Fri, 23 Feb 2018 14:38:30 +0100 | |
4 | Subject: serial: fsl_lpuart: Fix out-of-bounds access through DT alias | |
5 | ||
6 | From: Geert Uytterhoeven <geert+renesas@glider.be> | |
7 | ||
8 | [ Upstream commit ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47 ] | |
9 | ||
10 | The lpuart_ports[] array is indexed using a value derived from the | |
11 | "serialN" alias in DT, which may lead to an out-of-bounds access. | |
12 | ||
13 | Fix this by adding a range check. | |
14 | ||
15 | Fixes: c9e2e946fb0ba5d2 ("tty: serial: add Freescale lpuart driver support") | |
16 | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> | |
17 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
18 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
19 | --- | |
20 | drivers/tty/serial/fsl_lpuart.c | 4 ++++ | |
21 | 1 file changed, 4 insertions(+) | |
22 | ||
23 | --- a/drivers/tty/serial/fsl_lpuart.c | |
24 | +++ b/drivers/tty/serial/fsl_lpuart.c | |
25 | @@ -2151,6 +2151,10 @@ static int lpuart_probe(struct platform_ | |
26 | dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); | |
27 | return ret; | |
28 | } | |
29 | + if (ret >= ARRAY_SIZE(lpuart_ports)) { | |
30 | + dev_err(&pdev->dev, "serial%d out of range\n", ret); | |
31 | + return -EINVAL; | |
32 | + } | |
33 | sport->port.line = ret; | |
34 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
35 | sport->port.membase = devm_ioremap_resource(&pdev->dev, res); |