]> git.itanic.dy.fi Git - linux-stable/commit
serial: ma35d1: Validate console index before assignment
authorAndi Shyti <andi.shyti@kernel.org>
Mon, 4 Dec 2023 16:38:03 +0000 (17:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:45:31 +0000 (18:45 +0100)
commitc88a91ca26b102042e816fdf850fa51d10be4749
treeb1cc9ae862d4d91cf63bc3bea2c6af54c045bcf8
parent977a60f0639fbeea0161e6ce516c8d2f3dbefe78
serial: ma35d1: Validate console index before assignment

commit f0b9d97a77fa8f18400450713358303a435ab688 upstream.

The console is immediately assigned to the ma35d1 port without
checking its index. This oversight can lead to out-of-bounds
errors when the index falls outside the valid '0' to
MA35_UART_NR range. Such scenario trigges ran error like the
following:

 UBSAN: array-index-out-of-bounds in drivers/tty/serial/ma35d1_serial.c:555:51
 index -1 is out of range for type 'uart_ma35d1_port [17]

Check the index before using it and bail out with a warning.

Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support")
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Cc: Jacky Huang <ychuang3@nuvoton.com>
Cc: <stable@vger.kernel.org> # v6.5+
Link: https://lore.kernel.org/r/20231204163804.1331415-2-andi.shyti@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/ma35d1_serial.c