Skip to content

Commit 06b1cf3

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: spcp8x5: fix modem-status handling
commit 5ed8d41023751bdd3546f2fe4118304357efe8d2 upstream. Make sure to detect short control transfers and return zero on success when retrieving the modem status. This fixes the TIOCMGET implementation which since e1ed212 ("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. Fixes: e1ed212 ("USB: spcp8x5: add proper modem-status support") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 22034ee commit 06b1cf3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/usb/serial/spcp8x5.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,17 @@ static int spcp8x5_get_msr(struct usb_serial_port *port, u8 *status)
232232
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
233233
GET_UART_STATUS, GET_UART_STATUS_TYPE,
234234
0, GET_UART_STATUS_MSR, buf, 1, 100);
235-
if (ret < 0)
235+
if (ret < 1) {
236236
dev_err(&port->dev, "failed to get modem status: %d\n", ret);
237+
if (ret >= 0)
238+
ret = -EIO;
239+
goto out;
240+
}
237241

238242
dev_dbg(&port->dev, "0xc0:0x22:0:6 %d - 0x02%x\n", ret, *buf);
239243
*status = *buf;
244+
ret = 0;
245+
out:
240246
kfree(buf);
241247

242248
return ret;

0 commit comments

Comments
 (0)