diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2026-07-13 21:49:25 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2026-07-14 11:01:33 +0200 |
| commit | ffa0aa5b625fe0bed7463ac613f8b06676ff4542 (patch) | |
| tree | 1ee823d6b6e55ca0727114f8a18f063da7f7a2e5 /arch/x86/boot | |
| parent | d130041a7b96f79cd4c7079a6c2431a6db4c9619 (diff) | |
| download | linux-next-ffa0aa5b625fe0bed7463ac613f8b06676ff4542.tar.gz linux-next-ffa0aa5b625fe0bed7463ac613f8b06676ff4542.zip | |
x86/boot: Validate console=uart8250 baud rate to fix early boot hang
When the baud rate is empty, 0, invalid, or overflows to 0 when stored
as an int, the system will hang during early boot because of a division
by zero in early_serial_init().
Fall back to DEFAULT_BAUD when the resulting baud rate is 0 to prevent
an early system hang.
Fixes: ce0aa5dd20e4 ("x86, setup: Make the setup code also accept console=uart8250")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260713194924.126472-3-thorsten.blum@linux.dev
Diffstat (limited to 'arch/x86/boot')
| -rw-r--r-- | arch/x86/boot/early_serial_console.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c index 023bf1c3de8b..5b83beab89e1 100644 --- a/arch/x86/boot/early_serial_console.c +++ b/arch/x86/boot/early_serial_console.c @@ -117,7 +117,7 @@ static unsigned int probe_baud(int port) static void parse_console_uart8250(void) { char optstr[64], *options; - int baud = DEFAULT_BAUD; + int baud; int port = 0; /* @@ -136,10 +136,13 @@ static void parse_console_uart8250(void) else return; - if (options && (options[0] == ',')) - baud = simple_strtoull(options + 1, &options, 0); - else + if (options && (options[0] == ',')) { + baud = simple_strtoull(options + 1, NULL, 0); + if (!baud) + baud = DEFAULT_BAUD; + } else { baud = probe_baud(port); + } if (port) early_serial_init(port, baud); |
