serial: imx: Fix out-of-bounds access through serial port index
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 23 Feb 2018 13:38:31 +0000 (14:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 May 2018 14:13:14 +0000 (16:13 +0200)
commita301f13f34b8359f4844b2961789afbfc10bd21d
treeaac39e6f2a3a21b8762cab7ce16ba791177c4b14
parent2e876eae48736674bf2c5caa9c49566dffabb991
serial: imx: Fix out-of-bounds access through serial port index

[ Upstream commit 5673444821406dda5fc25e4b52aca419f8065a19 ]

The imx_ports[] 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: ff05967a07225ab6 ("serial/imx: add of_alias_get_id() reference back")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c