usb: class: cdc-wdm: return the correct errno code
authorJunlin Yang <yangjunlin@yulong.com>
Mon, 21 Jun 2021 13:24:15 +0000 (21:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jun 2021 12:11:26 +0000 (14:11 +0200)
The "rv" is initialized to "-ENOMEM", because "rv" is re-assigned to
"-EINVAL", when kmalloc & usb_alloc_urb failed, the return value should
return "-ENOMEM" rather than "-EINVAL",so the "rv" assignment is placed
in the position where usb_endpoint_is_int_in is false.

Acked-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
Link: https://lore.kernel.org/r/20210621132415.2341-1-angkery@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c

index d1e4a73..2c63c05 100644 (file)
@@ -868,9 +868,10 @@ static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor
        INIT_WORK(&desc->rxwork, wdm_rxwork);
        INIT_WORK(&desc->service_outs_intr, service_interrupt_work);
 
-       rv = -EINVAL;
-       if (!usb_endpoint_is_int_in(ep))
+       if (!usb_endpoint_is_int_in(ep)) {
+               rv = -EINVAL;
                goto err;
+       }
 
        desc->wMaxPacketSize = usb_endpoint_maxp(ep);