]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
USB: serial: ti_usb_3410_5052: fix control-message error handling
authorJohan Hovold <johan@kernel.org>
Thu, 12 Jan 2017 13:56:23 +0000 (14:56 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 20 Jun 2017 10:16:37 +0000 (12:16 +0200)
BugLink: http://bugs.launchpad.net/bugs/1691418
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>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/usb/serial/ti_usb_3410_5052.c

index 535fcfafc0977a8c56010c2c8c52b0def075b070..fe7f5ace60640929e91d007a94ce963f12be172d 100644 (file)
@@ -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;