summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-01-12 14:56:11 +0100
committerBen Hutchings <ben@decadent.org.uk>2017-06-05 21:13:42 +0100
commitc874cde1a49694c863acf7921da32769187f4fc9 (patch)
tree9f75c653a565d28fc1ef6d756a5269230232f3c4
parente75249fae4d90f954b04e88b205df91811d6f346 (diff)
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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/usb/serial/ftdi_sio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index dbc437c61fb5..43e1c392817c 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2542,8 +2542,13 @@ static int ftdi_tiocmget(struct tty_struct *tty)
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) {
+ if (ret >= 0)
+ ret = -EIO;
goto out;
+ }
ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |