diff options
author | Johan Hovold <johan@kernel.org> | 2017-01-12 16:56:11 +0300 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-01-16 18:38:55 +0300 |
commit | 427c3a95e3e29e65f59d99aaf320d7506f3eed57 (patch) | |
tree | ef6ec9ae9040988324add87baaf33ecbde1e1302 /drivers/usb/serial/ftdi_sio.c | |
parent | b631433b175f1002a31020e09bbfc2e5caecf290 (diff) | |
download | linux-427c3a95e3e29e65f59d99aaf320d7506f3eed57.tar.xz |
USB: serial: ftdi_sio: fix modem-status error handling
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: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 23d14b98ae2a..6dee20fc7e45 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -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; } |