]>
Commit | Line | Data |
---|---|---|
b74db2ac GKH |
1 | From 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 Mon Sep 17 00:00:00 2001 |
2 | From: Johan Hovold <johan@kernel.org> | |
3 | Date: Thu, 12 Jan 2017 14:56:23 +0100 | |
4 | Subject: USB: serial: ti_usb_3410_5052: fix control-message error handling | |
5 | ||
6 | From: Johan Hovold <johan@kernel.org> | |
7 | ||
8 | commit 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 upstream. | |
9 | ||
10 | Make sure to detect and return an error on zero-length control-message | |
11 | transfers when reading from the device. | |
12 | ||
13 | This addresses a potential failure to detect an empty transmit buffer | |
14 | during close. | |
15 | ||
16 | Also remove a redundant check for short transfer when sending a command. | |
17 | ||
18 | Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") | |
19 | Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
20 | Signed-off-by: Johan Hovold <johan@kernel.org> | |
21 | Signed-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; |