diff options
author | Johan Hovold <johan@kernel.org> | 2017-01-12 08:56:23 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-14 08:00:19 -0400 |
commit | 94bbbfe21b5a592dc5306f2203d6716734cf9b67 (patch) | |
tree | 8134d183bef3a30a72c0dbc3e6f325d1e2457ac1 | |
parent | b07e930d1f498e3cc3677fdf89665918aa44e244 (diff) |
USB: serial: ti_usb_3410_5052: fix control-message error handling
commit 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 upstream.
Make sure to detect and return an error on zero-length control-message
transfers when reading from the device.
This addresses a potential failure to detect an empty transmit buffer
during close.
Also remove a redundant check for short transfer when sending a command.
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>
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index bdbddbc8bd4d..6bcb874b4832 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1556,13 +1556,10 @@ static int ti_command_out_sync(struct ti_device *tdev, __u8 command, | |||
1556 | (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), | 1556 | (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), |
1557 | value, moduleid, data, size, 1000); | 1557 | value, moduleid, data, size, 1000); |
1558 | 1558 | ||
1559 | if (status == size) | 1559 | if (status < 0) |
1560 | status = 0; | 1560 | return status; |
1561 | |||
1562 | if (status > 0) | ||
1563 | status = -ECOMM; | ||
1564 | 1561 | ||
1565 | return status; | 1562 | return 0; |
1566 | } | 1563 | } |
1567 | 1564 | ||
1568 | 1565 | ||
@@ -1578,8 +1575,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, | |||
1578 | 1575 | ||
1579 | if (status == size) | 1576 | if (status == size) |
1580 | status = 0; | 1577 | status = 0; |
1581 | 1578 | else if (status >= 0) | |
1582 | if (status > 0) | ||
1583 | status = -ECOMM; | 1579 | status = -ECOMM; |
1584 | 1580 | ||
1585 | return status; | 1581 | return status; |