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

usb: return correct errno on failures

In function __wa_xfer_setup_segs(), variable result takes the return
value. Its value should be a negative errno on failures. Because result
may be reassigned in a loop, and its value is guaranteed to be not less
than 0 during the following repeats of the loop. So when the call to
kmalloc() or usb_alloc_urb() fails in the loop, the value of variable
result may be 0 (indicates no error), which is inconsistent with the
execution status. This patch fixes the bug, initializing variable result
with -ENOMEM in the loop.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Pan Bian and committed by
Greg Kroah-Hartman
cd63a1c1 fca0ca95

+1
+1
drivers/usb/wusbcore/wa-xfer.c
··· 1203 1203 sizeof(struct wa_xfer_packet_info_hwaiso) + 1204 1204 (seg_isoc_frame_count * sizeof(__le16)); 1205 1205 } 1206 + result = -ENOMEM; 1206 1207 seg = xfer->seg[cnt] = kmalloc(alloc_size + iso_pkt_descr_size, 1207 1208 GFP_ATOMIC); 1208 1209 if (seg == NULL)