Skip to content

Commit

Permalink
USB: serial: ftdi_sio: fix latency-timer error handling
Browse files Browse the repository at this point in the history
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: 1da177e ("Linux-2.6.12-rc2")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Johan Hovold committed Jan 16, 2017
1 parent 427c3a9 commit e3e574a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e3e574a

Please sign in to comment.