forked from Minki/linux
USB: wusb: don't leak urb in certain error cases
Don't leak an urb in wusb_dev_alloc() if the following kmalloc() failed. Reported-by: Julia Lawall <julia@diku.dk> Signed-off-by: David Vrabel <david.vrabel@csr.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
0d370755dd
commit
2e9729d0f8
@ -119,10 +119,12 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
|
|||||||
urb = usb_alloc_urb(0, GFP_KERNEL);
|
urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||||
if (urb == NULL)
|
if (urb == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
wusb_dev->set_gtk_urb = urb;
|
||||||
|
|
||||||
req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
|
req = kmalloc(sizeof(*req), GFP_KERNEL);
|
||||||
if (req == NULL)
|
if (req == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
|
wusb_dev->set_gtk_req = req;
|
||||||
|
|
||||||
req->bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
|
req->bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
|
||||||
req->bRequest = USB_REQ_SET_DESCRIPTOR;
|
req->bRequest = USB_REQ_SET_DESCRIPTOR;
|
||||||
@ -130,9 +132,6 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
|
|||||||
req->wIndex = 0;
|
req->wIndex = 0;
|
||||||
req->wLength = cpu_to_le16(wusbhc->gtk.descr.bLength);
|
req->wLength = cpu_to_le16(wusbhc->gtk.descr.bLength);
|
||||||
|
|
||||||
wusb_dev->set_gtk_urb = urb;
|
|
||||||
wusb_dev->set_gtk_req = req;
|
|
||||||
|
|
||||||
return wusb_dev;
|
return wusb_dev;
|
||||||
err:
|
err:
|
||||||
wusb_dev_free(wusb_dev);
|
wusb_dev_free(wusb_dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user