Skip to content

Commit fb4d672

Browse files
jhovoldgregkh
authored andcommitted
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: 1da177e ("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>
1 parent 5fbabc9 commit fb4d672

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

drivers/usb/serial/ti_usb_3410_5052.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,13 +1352,10 @@ static int ti_command_out_sync(struct ti_device *tdev, __u8 command,
13521352
(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
13531353
value, moduleid, data, size, 1000);
13541354

1355-
if (status == size)
1356-
status = 0;
1357-
1358-
if (status > 0)
1359-
status = -ECOMM;
1355+
if (status < 0)
1356+
return status;
13601357

1361-
return status;
1358+
return 0;
13621359
}
13631360

13641361

@@ -1374,8 +1371,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
13741371

13751372
if (status == size)
13761373
status = 0;
1377-
1378-
if (status > 0)
1374+
else if (status >= 0)
13791375
status = -ECOMM;
13801376

13811377
return status;

0 commit comments

Comments
 (0)