Skip to content

Commit af82872

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: ftdi_sio: fix modem-status error handling
commit 427c3a95e3e29e65f59d99aaf320d7506f3eed57 upstream. Make 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. Fixes: 1da177e ("Linux-2.6.12-rc2") 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 bcea8e9 commit af82872

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/usb/serial/ftdi_sio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2433,8 +2433,12 @@ static int ftdi_get_modem_status(struct usb_serial_port *port,
24332433
FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
24342434
0, priv->interface,
24352435
buf, len, WDR_TIMEOUT);
2436-
if (ret < 0) {
2436+
2437+
/* NOTE: We allow short responses and handle that below. */
2438+
if (ret < 1) {
24372439
dev_err(&port->dev, "failed to get modem status: %d\n", ret);
2440+
if (ret >= 0)
2441+
ret = -EIO;
24382442
ret = usb_translate_errors(ret);
24392443
goto out;
24402444
}

0 commit comments

Comments
 (0)