Skip to content

Commit 1e6e9c4

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: io_ti: fix div-by-zero in set_termios
commit 6aeb75e6adfaed16e58780309613a578fe1ee90b upstream. Fix a division-by-zero in set_termios when debugging is enabled and a high-enough speed has been requested so that the divisor value becomes zero. Instead of just fixing the offending debug statement, cap the baud rate at the base as a zero divisor value also appears to crash the firmware. Fixes: 1da177e ("Linux-2.6.12-rc2") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4be0ae3 commit 1e6e9c4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/usb/serial/io_ti.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2349,8 +2349,11 @@ static void change_port_settings(struct tty_struct *tty,
23492349
if (!baud) {
23502350
/* pick a default, any default... */
23512351
baud = 9600;
2352-
} else
2352+
} else {
2353+
/* Avoid a zero divisor. */
2354+
baud = min(baud, 461550);
23532355
tty_encode_baud_rate(tty, baud, baud);
2356+
}
23542357

23552358
edge_port->baud_rate = baud;
23562359
config->wBaudRate = (__u16)((461550L + baud/2) / baud);

0 commit comments

Comments
 (0)