Commit 2a635375 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: serial: io_ti: fix div-by-zero in set_termios

commit 6aeb75e6 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: 1da177e4 ("Linux-2.6.12-rc2")
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2d19b3e0
...@@ -2210,8 +2210,11 @@ static void change_port_settings(struct tty_struct *tty, ...@@ -2210,8 +2210,11 @@ static void change_port_settings(struct tty_struct *tty,
if (!baud) { if (!baud) {
/* pick a default, any default... */ /* pick a default, any default... */
baud = 9600; baud = 9600;
} else } else {
/* Avoid a zero divisor. */
baud = min(baud, 461550);
tty_encode_baud_rate(tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
}
edge_port->baud_rate = baud; edge_port->baud_rate = baud;
config->wBaudRate = (__u16)((461550L + baud/2) / baud); config->wBaudRate = (__u16)((461550L + baud/2) / baud);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment