summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrigor Tovmasyan <Grigor.Tovmasyan@synopsys.com>2018-05-24 18:22:30 +0400
committerFelipe Balbi <felipe.balbi@linux.intel.com>2018-06-19 12:48:14 +0300
commit9bb073a053f0464ea74a4d4c331fdb7da58568d6 (patch)
tree9327045eefd467b1a6e7f95e30b3eca167fef996 /drivers
parent980900d6318066b9f8314bfb87329a20fd0d1ca4 (diff)
downloadlinux-stable-9bb073a053f0464ea74a4d4c331fdb7da58568d6.tar.gz
linux-stable-9bb073a053f0464ea74a4d4c331fdb7da58568d6.tar.bz2
linux-stable-9bb073a053f0464ea74a4d4c331fdb7da58568d6.zip
usb: gadget: dwc2: fix memory leak in gadget_init()
Freed allocated request for ep0 to prevent memory leak in case when dwc2_driver_probe() failed. Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Minas Harutyunyan <hminas@synopsys.com> Signed-off-by: Grigor Tovmasyan <tovmasya@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/dwc2/gadget.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index fa3b6f361074..76e4f2e7d947 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4735,9 +4735,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
}
ret = usb_add_gadget_udc(dev, &hsotg->gadget);
- if (ret)
+ if (ret) {
+ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
+ hsotg->ctrl_req);
return ret;
-
+ }
dwc2_hsotg_dump(hsotg);
return 0;
@@ -4751,6 +4753,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
{
usb_del_gadget_udc(&hsotg->gadget);
+ dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
return 0;
}