USB: WUSBCORE: fix resource cleanup in error path in __wa_xfer_setup_segs
authorThomas Pugliese <thomas.pugliese@gmail.com>
Thu, 15 Aug 2013 19:37:41 +0000 (14:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Aug 2013 00:36:27 +0000 (17:36 -0700)
Use usb_free_urb instead of kfree in error path and point to the correct
URB.  Also remember to clean up the sg list for the URB if it was allocated.

Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/wusbcore/wa-xfer.c

index d74fe1ae16acb5cd024712fe192e832aa96f1cca..75a2bea62102a08bfab8f57d1848d6d6d984121d 100644 (file)
@@ -804,15 +804,17 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size)
        return 0;
 
 error_sg_alloc:
-       kfree(seg->dto_urb);
+       usb_free_urb(xfer->seg[cnt]->dto_urb);
 error_dto_alloc:
        kfree(xfer->seg[cnt]);
        cnt--;
 error_seg_kzalloc:
        /* use the fact that cnt is left at were it failed */
        for (; cnt >= 0; cnt--) {
-               if (xfer->seg[cnt] && xfer->is_inbound == 0)
+               if (xfer->seg[cnt] && xfer->is_inbound == 0) {
                        usb_free_urb(xfer->seg[cnt]->dto_urb);
+                       kfree(xfer->seg[cnt]->dto_urb->sg);
+               }
                kfree(xfer->seg[cnt]);
        }
 error_segs_kzalloc: