serial: 8250: Check for valid console index

Let's not allow negative numbers for console index.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20231004085511.42645-1-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tony Lindgren 2023-10-04 11:55:10 +03:00 committed by Greg Kroah-Hartman
parent 0d447e927e
commit b9cbe7e8f2

View File

@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)
* if so, search for the first available port that does have
* console support.
*/
if (co->index >= UART_NR)
if (co->index < 0 || co->index >= UART_NR)
co->index = 0;
/*