[PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault

From: Biju

Date: Wed Apr 08 2026 - 10:26:37 EST


From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

uart_update_timeout() computes a timeout value by dividing by the baud
rate. If baud is zero — which can occur when the hardware returns an
unsupported or invalid rate — this results in a divide-by-zero fault.

Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
v2:
* New patch
---
drivers/tty/serial/rsci.c | 3 ++-
drivers/tty/serial/sh-sci.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index b00c9e385169..a0858bab0822 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
sci_port_enable(s);
uart_port_lock_irqsave(port, &flags);

- uart_update_timeout(port, termios->c_cflag, baud);
+ if (baud)
+ uart_update_timeout(port, termios->c_cflag, baud);

rsci_serial_out(port, CCR0, ccr0_val);

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 6c819b6b2425..429e89106ee3 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,

sci_reset(port);

- uart_update_timeout(port, termios->c_cflag, baud);
+ if (baud)
+ uart_update_timeout(port, termios->c_cflag, baud);

/* byte size and parity */
bits = tty_get_frame_size(termios->c_cflag);
--
2.43.0