Skip to content

Commit

Permalink
USB: wusb: don't leak urb in certain error cases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Vrabel authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent 0d37075 commit 2e9729d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/usb/wusbcore/devconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,19 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
urb = usb_alloc_urb(0, GFP_KERNEL);
if (urb == NULL)
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)
goto err;
wusb_dev->set_gtk_req = req;

req->bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
req->bRequest = USB_REQ_SET_DESCRIPTOR;
req->wValue = cpu_to_le16(USB_DT_KEY << 8 | wusbhc->gtk_index);
req->wIndex = 0;
req->wLength = cpu_to_le16(wusbhc->gtk.descr.bLength);

wusb_dev->set_gtk_urb = urb;
wusb_dev->set_gtk_req = req;

return wusb_dev;
err:
wusb_dev_free(wusb_dev);
Expand Down

0 comments on commit 2e9729d

Please sign in to comment.