Skip to content

Commit 6aeb75e

Browse files
committed
USB: serial: io_ti: fix div-by-zero in set_termios
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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable <stable@vger.kernel.org> # 2.6.12 Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
1 parent 26cede3 commit 6aeb75e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: drivers/usb/serial/io_ti.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2336,8 +2336,11 @@ static void change_port_settings(struct tty_struct *tty,
23362336
if (!baud) {
23372337
/* pick a default, any default... */
23382338
baud = 9600;
2339-
} else
2339+
} else {
2340+
/* Avoid a zero divisor. */
2341+
baud = min(baud, 461550);
23402342
tty_encode_baud_rate(tty, baud, baud);
2343+
}
23412344

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

0 commit comments

Comments
 (0)