Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: mxs-auart: Fix out-of-bounds access through serial port index

The auart_port[] array is indexed using a value derived from the
"serialN" alias in DT, or from platform data, which may lead to an
out-of-bounds access.

Fix this by adding a range check.

Fixes: 1ea6607d4cdc9179 ("serial: mxs-auart: Allow device tree probing")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Geert Uytterhoeven and committed by
Greg Kroah-Hartman
dd345a31 56734448

+4
+4
drivers/tty/serial/mxs-auart.c
··· 1663 1663 s->port.line = pdev->id < 0 ? 0 : pdev->id; 1664 1664 else if (ret < 0) 1665 1665 return ret; 1666 + if (s->port.line >= ARRAY_SIZE(auart_port)) { 1667 + dev_err(&pdev->dev, "serial%d out of range\n", s->port.line); 1668 + return -EINVAL; 1669 + } 1666 1670 1667 1671 if (of_id) { 1668 1672 pdev->id_entry = of_id->data;