Skip to content

Commit

Permalink
usb: dwc3: gadget: avoid memory leak when failing to allocate all eps
Browse files Browse the repository at this point in the history
If dwc3_gadget_init_endpoint() fails after allocate some of the eps, we
need to free their memory to avoid leak.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
David Cohen authored and Felipe Balbi committed Sep 17, 2013
1 parent bbaa7c8 commit e1f8046
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2611,15 +2611,13 @@ int dwc3_gadget_init(struct dwc3 *dwc)
ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget);
if (ret) {
dev_err(dwc->dev, "failed to register udc\n");
goto err5;
goto err4;
}

return 0;

err5:
dwc3_gadget_free_endpoints(dwc);

err4:
dwc3_gadget_free_endpoints(dwc);
dma_free_coherent(dwc->dev, DWC3_EP0_BOUNCE_SIZE,
dwc->ep0_bounce, dwc->ep0_bounce_addr);

Expand Down

0 comments on commit e1f8046

Please sign in to comment.