USB: serial: ftdi_sio: fix latency-timer error handling
authorJohan Hovold <johan@kernel.org>
Thu, 12 Jan 2017 13:56:12 +0000 (14:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 May 2017 11:32:56 +0000 (13:32 +0200)
commit e3e574ad85a208cb179f33720bb5f12b453de33c upstream.

Make sure to detect short responses when reading the latency timer to
avoid using stale buffer data.

Note that no heap data would currently leak through sysfs as
ASYNC_LOW_LATENCY is set by default.

Fixes: 1da177e4c3f4 ("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>
drivers/usb/serial/ftdi_sio.c

index 19a98116c2ab08c9778c969f591c1152b7e8a71b..b3a21fcbbaf902c51e7b1c13dc54a8913b500589 100644 (file)
@@ -1439,10 +1439,13 @@ static int read_latency_timer(struct usb_serial_port *port)
                             FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
                             0, priv->interface,
                             buf, 1, WDR_TIMEOUT);
-       if (rv < 0)
+       if (rv < 1) {
                dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
-       else
+               if (rv >= 0)
+                       rv = -EIO;
+       } else {
                priv->latency = buf[0];
+       }
 
        kfree(buf);