diff options
| author | Johan Hovold <johan@kernel.org> | 2017-01-12 14:56:23 +0100 |
|---|---|---|
| committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-13 09:29:20 -0400 |
| commit | b5b985c3a0bd5750d85b794cb61c2623194f1459 (patch) | |
| tree | f2f72aa522ec3dfacf26d1723b1cbd7bd35102db | |
| parent | dc7697bad3f65182e23541ce6279703cec643bb7 (diff) | |
| download | linux-b5b985c3a0bd5750d85b794cb61c2623194f1459.tar.gz linux-b5b985c3a0bd5750d85b794cb61c2623194f1459.tar.bz2 linux-b5b985c3a0bd5750d85b794cb61c2623194f1459.zip | |
USB: serial: ti_usb_3410_5052: fix control-message error handling
[ Upstream commit 39712e8bfa8d3aa6ce1e60fc9d62c9b076c17a30 ]
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: Sasha Levin <alexander.levin@verizon.com>
| -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 535fcfafc097..fe7f5ace6064 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -1352,13 +1352,10 @@ static int ti_command_out_sync(struct ti_device *tdev, __u8 command, (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), value, moduleid, data, size, 1000); - if (status == size) - status = 0; - - if (status > 0) - status = -ECOMM; + if (status < 0) + return status; - return status; + return 0; } @@ -1374,8 +1371,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, if (status == size) status = 0; - - if (status > 0) + else if (status >= 0) status = -ECOMM; return status; |
