Skip to content

Commit

Permalink
USB: serial: io_ti: fix div-by-zero in set_termios
Browse files Browse the repository at this point in the history
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")
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>
  • Loading branch information
Johan Hovold committed May 15, 2017
1 parent 26cede3 commit 6aeb75e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/serial/io_ti.c
Original file line number Diff line number Diff line change
Expand Up @@ -2336,8 +2336,11 @@ static void change_port_settings(struct tty_struct *tty,
if (!baud) {
/* pick a default, any default... */
baud = 9600;
} else
} else {
/* Avoid a zero divisor. */
baud = min(baud, 461550);
tty_encode_baud_rate(tty, baud, baud);
}

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

0 comments on commit 6aeb75e

Please sign in to comment.