Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: class: cdc-wdm: return the correct errno code

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>

authored by

Junlin Yang and committed by
Greg Kroah-Hartman
42601e35 8e9910c5

+3 -2
+3 -2
drivers/usb/class/cdc-wdm.c
··· 868 868 INIT_WORK(&desc->rxwork, wdm_rxwork); 869 869 INIT_WORK(&desc->service_outs_intr, service_interrupt_work); 870 870 871 - rv = -EINVAL; 872 - if (!usb_endpoint_is_int_in(ep)) 871 + if (!usb_endpoint_is_int_in(ep)) { 872 + rv = -EINVAL; 873 873 goto err; 874 + } 874 875 875 876 desc->wMaxPacketSize = usb_endpoint_maxp(ep); 876 877