summaryrefslogtreecommitdiff
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorDavid Cohen <david.a.cohen@linux.intel.com>2013-09-11 17:42:47 -0700
committerFelipe Balbi <balbi@ti.com>2013-09-17 11:05:01 -0500
commite1f804676a95b9d5caaa3a822d90bc1101595468 (patch)
treec48ac2f81d78af981ea2415b4a6dc10178956c6d /drivers/usb/dwc3
parentbbaa7c81e61e339fbc6aae2594c7ce8f54196fa7 (diff)
usb: dwc3: gadget: avoid memory leak when failing to allocate all eps
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>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/gadget.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index f168eaebdef8..5452c0fce360 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -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);