summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-05-11 12:41:21 +0300
committerBen Hutchings <ben@decadent.org.uk>2017-09-15 20:30:41 +0300
commit5b044cee0ef9b5f61bca80be15a019eb4ffa6a09 (patch)
tree7cf9be5720671cb50c878c12acc777c403c02e94 /drivers
parent18b1af6c5c26c204edb75b9dad5aab2208a7a6a6 (diff)
downloadlinux-5b044cee0ef9b5f61bca80be15a019eb4ffa6a09.tar.xz
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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/serial/io_ti.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index a4177561d09a..86c8efd49583 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2412,8 +2412,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);