In uart_get_baud_rate(), when a custom divisor is requested, if port->uartclk is zero, the fallback logic evaluates baud = port->uartclk / 16 which results in baud = 0, causing a divide-by-zero error in subsequent calculations. Ensure uart_get_baud_rate() falls back to a valid default baud rate when port->uartclk is zero. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Assisted-by: LLM Signed-off-by: Hui Peng --- drivers/tty/serial/serial_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 95774b0f1484..55bb1eaa27e7 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -480,6 +480,11 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, return 0; max = port->uartclk / 16; + if (!max) + max = 115200; + if (termios) { baud = tty_termios_baud_rate(termios);