serial: sirf: Fix out-of-bounds access through DT alias
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 23 Feb 2018 13:38:36 +0000 (14:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Feb 2018 14:30:00 +0000 (15:30 +0100)
commit96c611c2b7bc897a6d16d58c76751f48707a4ac5
treef11c899eba93e9783c87d07a989b0e6fd27b02b0
parent090fa4b0dccfa3d04e1c5ab0fe4eba16e6713895
serial: sirf: Fix out-of-bounds access through DT alias

The sirf_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: a6ffe8966acbb66b ("serial: sirf: use dynamic method allocate uart structure")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sirfsoc_uart.c