]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serial: 8250: Check for valid console index
authorTony Lindgren <tony@atomide.com>
Wed, 4 Oct 2023 08:55:10 +0000 (11:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Oct 2023 07:41:17 +0000 (09:41 +0200)
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>
drivers/tty/serial/8250/8250_core.c

index 904e319e6b4a3576eca555af04e0c1fac91a7d35..912733151858760bdab550be2bd261db296f68d3 100644 (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;
 
        /*