]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.28/usb-serial-ftdi_sio-fix-latency-timer-error-handling.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / usb-serial-ftdi_sio-fix-latency-timer-error-handling.patch
1 From e3e574ad85a208cb179f33720bb5f12b453de33c Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <johan@kernel.org>
3 Date: Thu, 12 Jan 2017 14:56:12 +0100
4 Subject: USB: serial: ftdi_sio: fix latency-timer error handling
5
6 From: Johan Hovold <johan@kernel.org>
7
8 commit e3e574ad85a208cb179f33720bb5f12b453de33c upstream.
9
10 Make sure to detect short responses when reading the latency timer to
11 avoid using stale buffer data.
12
13 Note that no heap data would currently leak through sysfs as
14 ASYNC_LOW_LATENCY is set by default.
15
16 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
17 Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 Signed-off-by: Johan Hovold <johan@kernel.org>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/usb/serial/ftdi_sio.c | 7 +++++--
23 1 file changed, 5 insertions(+), 2 deletions(-)
24
25 --- a/drivers/usb/serial/ftdi_sio.c
26 +++ b/drivers/usb/serial/ftdi_sio.c
27 @@ -1439,10 +1439,13 @@ static int read_latency_timer(struct usb
28 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
29 0, priv->interface,
30 buf, 1, WDR_TIMEOUT);
31 - if (rv < 0)
32 + if (rv < 1) {
33 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv);
34 - else
35 + if (rv >= 0)
36 + rv = -EIO;
37 + } else {
38 priv->latency = buf[0];
39 + }
40
41 kfree(buf);
42