arch/x86/boot/early_serial_console.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
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")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/x86/boot/early_serial_console.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 023bf1c3de8b..28a887af430d 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,9 +136,11 @@ 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)
On Thu, May 14, 2026 at 04:30:15PM +0200, Thorsten Blum wrote:
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> arch/x86/boot/early_serial_console.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
> index 023bf1c3de8b..28a887af430d 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,9 +136,11 @@ 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)
Gentle ping?
I also tested this and verified that it works.
© 2016 - 2026 Red Hat, Inc.