USB: serial: spcp8x5: fix modem-status handling
Subsystems (3)
Johan Hovold
maintainerPATCH 13/15 USB: serial: spcp8x5: fix modem-status handling
In reply to a message not in the archiveMake sure to detect short control transfers and return zero on success when retrieving the modem status.
This fixes the TIOCMGET implementation which since e1ed212d8593 ("USB:
spcp8x5: add proper modem-status support") has returned TIOCM_LE on successful retrieval, and avoids leaking bits from the stack on short transfers.
This also fixes the carrier-detect implementation which since the above mentioned commit unconditionally has returned true.
--- drivers/usb/serial/spcp8x5.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/serial/spcp8x5.c +7 -1
@@ -232,11 +232,17 @@ static int spcp8x5_get_msr(struct usb_serial_port *port, u8 *status) ret =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ),GET_UART_STATUS ,GET_UART_STATUS_TYPE ,0 ,GET_UART_STATUS_MSR , buf,1 ,100 ); -if (ret <0 ) +if (ret <1 ) {dev_err (&port->dev,"failed to get modem status: %d\n" , ret); +if (ret >=0 ) + ret = -EIO ; + goto out; + }dev_dbg (&port->dev,"0xc0:0x22:0:6 %d - 0x02%x\n" , ret, *buf); *status = *buf; + ret =0 ; +out:kfree (buf);return ret;
Signature · 1 line
2.10.2
Johan Hovold
maintainerPATCH 3/15 USB: serial: ftdi_sio: fix modem-status error handling
In reply to a message not in the archiveMake sure to detect short responses when fetching the modem status in order to avoid parsing uninitialised buffer data and having bits of it leak to user space.
Note that we still allow for short 1-byte responses.
--- drivers/usb/serial/ftdi_sio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/serial/ftdi_sio.c +5 -1
@@ -2428,8 +2428,12 @@ static int ftdi_get_modem_status(struct usb_serial_port *port,FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE ,0 , priv->interface, buf, len, WDR_TIMEOUT); -if (ret <0 ) { + +/* NOTE: We allow short responses and handle that below. */ +if (ret <1 ) {dev_err (&port->dev,"failed to get modem status: %d\n" , ret); +if (ret >=0 ) + ret = -EIO ; ret =usb_translate_errors (ret); goto out; }
Signature · 1 line
2.10.2
Johan Hovold
maintainerPATCH 1/15 USB: serial: ark3116: fix register-accessor error handling
In reply to a message not in the archiveThe current implementation failed to detect short transfers, something which could lead to bits of the uninitialised heap transfer buffer leaking to user space.
new ark3116 driver.")
and add close and release functions.")
--- drivers/usb/serial/ark3116.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/usb/serial/ark3116.c +10 -3
@@ -99,10 +99,17 @@ static int ark3116_read_reg(struct usb_serial *serial,usb_rcvctrlpipe (serial->dev,0 ),0xfe ,0xc0 ,0 , reg, buf, 1, ARK_TIMEOUT); -if (result <0 ) +if (result <1 ) { +dev_err (&serial->interface->dev, +"failed to read register %u: %d\n" , + reg, result); +if (result >=0 ) + result = -EIO ; +return result; -else -return buf[0 ]; + } + +return buf[0 ]; }static inline int calc_divisor (int bps)
Signature · 1 line
2.10.2