usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i]
authorYoung Xiao <92siuyang@gmail.com>
Tue, 28 May 2019 12:17:54 +0000 (20:17 +0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 6 Jun 2019 10:51:57 +0000 (13:51 +0300)
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: Young Xiao <92siuyang@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/fusb300_udc.c

index 263804d154a77d2d54e4809cde3a54e1387f3882..00e3f66836a982352bf3c3f31907fa3c9154df5a 100644 (file)
@@ -1342,12 +1342,15 @@ static const struct usb_gadget_ops fusb300_gadget_ops = {
 static int fusb300_remove(struct platform_device *pdev)
 {
        struct fusb300 *fusb300 = platform_get_drvdata(pdev);
+       int i;
 
        usb_del_gadget_udc(&fusb300->gadget);
        iounmap(fusb300->reg);
        free_irq(platform_get_irq(pdev, 0), fusb300);
 
        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);
 
        return 0;
@@ -1491,6 +1494,8 @@ clean_up:
                if (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);
        }
        if (reg)