]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
usb: return correct errno on failures
authorPan Bian <bianpan2016@163.com>
Tue, 29 Nov 2016 12:55:12 +0000 (20:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2016 16:36:43 +0000 (17:36 +0100)
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>
drivers/usb/wusbcore/wa-xfer.c

index 167fcc71f5f6e95b16f49028a1852d216a0b9e64..e70322b1dd020d27082273df2b394e1d526afabd 100644 (file)
@@ -1203,6 +1203,7 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size)
                                sizeof(struct wa_xfer_packet_info_hwaiso) +
                                (seg_isoc_frame_count * sizeof(__le16));
                }
+               result = -ENOMEM;
                seg = xfer->seg[cnt] = kmalloc(alloc_size + iso_pkt_descr_size,
                                                GFP_ATOMIC);
                if (seg == NULL)