USB: serial: mct_u232: fix big-endian baud-rate handling
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Johan Hovold
maintainerPATCH 2/3 USB: serial: mct_u232: fix big-endian baud-rate handling
Drop erroneous cpu_to_le32 when setting the baud rate, something which corrupted the divisor on big-endian hosts.
Found using sparse:
warning: incorrect type in argument 1 (different base types)
expected unsigned int [unsigned] [usertype] val got restricted __le32 [usertype] <noident>
--- drivers/usb/serial/mct_u232.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/mct_u232.c +1 -1
@@ -189,7 +189,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,return -ENOMEM ; divisor =mct_u232_calculate_baud_rate (serial, value, &speed); -put_unaligned_le32 (cpu_to_le32 (divisor), buf); +put_unaligned_le32 (divisor, buf); rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), MCT_U232_SET_BAUD_RATE_REQUEST, MCT_U232_SET_REQUEST_TYPE,
Signature · 1 line
2.13.0
drivers/usb/serial/mct_u232.c static int mct_u232_set_baud_rate(struct tty_struct *tty, · line 191
Quoted 9 lines · On Thu, 11 May 2017 11:41:20 +0200 Johan Hovold <[email protected]> wrote:
Drop erroneous
cpu_to_le32when setting the baud rate, something which corrupted the divisor on big-endian hosts.+++
b/drivers/usb/serial/mct_u232.cdrivers/usb/serial/mct_u232.c +1
-1@@ -189,7 +189,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, divisor =mct_u232_calculate_baud_rate (serial, value, &speed); -put_unaligned_le32 (cpu_to_le32 (divisor), buf); +put_unaligned_le32 (divisor, buf); rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-- Pete
Johan Hovold
maintainerPATCH 3/3 USB: serial: io_ti: fix div-by-zero in set_termios
In reply to a message not in the archiveFix 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.
--- drivers/usb/serial/io_ti.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/serial/io_ti.c +4 -1
@@ -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);
Signature · 1 line
2.13.0