Commit 40d283aa authored by Young Xiao's avatar Young Xiao Committed by Stefan Bader

usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i]

BugLink: https://bugs.launchpad.net/bugs/1836668

[ Upstream commit 62fd0e0a ]

There is no deallocation of fusb300->ep[i] elements, allocated at
fusb300_probe.

The patch adds deallocation of fusb300->ep array elements.
Signed-off-by: default avatarYoung Xiao <92siuyang@gmail.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent aaa246cf
...@@ -1345,12 +1345,15 @@ static const struct usb_gadget_ops fusb300_gadget_ops = { ...@@ -1345,12 +1345,15 @@ static const struct usb_gadget_ops fusb300_gadget_ops = {
static int fusb300_remove(struct platform_device *pdev) static int fusb300_remove(struct platform_device *pdev)
{ {
struct fusb300 *fusb300 = platform_get_drvdata(pdev); struct fusb300 *fusb300 = platform_get_drvdata(pdev);
int i;
usb_del_gadget_udc(&fusb300->gadget); usb_del_gadget_udc(&fusb300->gadget);
iounmap(fusb300->reg); iounmap(fusb300->reg);
free_irq(platform_get_irq(pdev, 0), fusb300); free_irq(platform_get_irq(pdev, 0), fusb300);
fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
for (i = 0; i < FUSB300_MAX_NUM_EP; i++)
kfree(fusb300->ep[i]);
kfree(fusb300); kfree(fusb300);
return 0; return 0;
...@@ -1494,6 +1497,8 @@ static int fusb300_probe(struct platform_device *pdev) ...@@ -1494,6 +1497,8 @@ static int fusb300_probe(struct platform_device *pdev)
if (fusb300->ep0_req) if (fusb300->ep0_req)
fusb300_free_request(&fusb300->ep[0]->ep, fusb300_free_request(&fusb300->ep[0]->ep,
fusb300->ep0_req); fusb300->ep0_req);
for (i = 0; i < FUSB300_MAX_NUM_EP; i++)
kfree(fusb300->ep[i]);
kfree(fusb300); kfree(fusb300);
} }
if (reg) if (reg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment