]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.28/usb-serial-ti_usb_3410_5052-fix-control-message-error-handling.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.28 / usb-serial-ti_usb_3410_5052-fix-control-message-error-handling.patch
CommitLineData
b74db2ac
GKH
1From 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 Mon Sep 17 00:00:00 2001
2From: Johan Hovold <johan@kernel.org>
3Date: Thu, 12 Jan 2017 14:56:23 +0100
4Subject: USB: serial: ti_usb_3410_5052: fix control-message error handling
5
6From: Johan Hovold <johan@kernel.org>
7
8commit 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 upstream.
9
10Make sure to detect and return an error on zero-length control-message
11transfers when reading from the device.
12
13This addresses a potential failure to detect an empty transmit buffer
14during close.
15
16Also remove a redundant check for short transfer when sending a command.
17
18Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
19Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20Signed-off-by: Johan Hovold <johan@kernel.org>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 drivers/usb/serial/ti_usb_3410_5052.c | 12 ++++--------
25 1 file changed, 4 insertions(+), 8 deletions(-)
26
27--- a/drivers/usb/serial/ti_usb_3410_5052.c
28+++ b/drivers/usb/serial/ti_usb_3410_5052.c
29@@ -1556,13 +1556,10 @@ static int ti_command_out_sync(struct ti
30 (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
31 value, moduleid, data, size, 1000);
32
33- if (status == size)
34- status = 0;
35-
36- if (status > 0)
37- status = -ECOMM;
38+ if (status < 0)
39+ return status;
40
41- return status;
42+ return 0;
43 }
44
45
46@@ -1578,8 +1575,7 @@ static int ti_command_in_sync(struct ti_
47
48 if (status == size)
49 status = 0;
50-
51- if (status > 0)
52+ else if (status >= 0)
53 status = -ECOMM;
54
55 return status;