Skip to content

Commit

Permalink
USB: serial: ti_usb_3410_5052: fix control-message error handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Hovold committed Jan 16, 2017
1 parent 1eac5c2 commit 39712e8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/usb/serial/ti_usb_3410_5052.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,13 +1553,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;
}


Expand All @@ -1575,8 +1572,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;
Expand Down

0 comments on commit 39712e8

Please sign in to comment.