]> git.sur5r.net Git - u-boot/commitdiff
usb: ci_udc: clean up all allocations in unregister
authorStephen Warren <swarren@nvidia.com>
Tue, 10 Jun 2014 17:02:38 +0000 (11:02 -0600)
committerMarek Vasut <marex@denx.de>
Wed, 11 Jun 2014 00:26:05 +0000 (02:26 +0200)
usb_gadget_unregister_driver() is called to tear down the USB device mode
stack. Fix the driver to stop the USB HW (which causes any attached host
to notice the disappearance of the device), and free all allocations
(which obviously prevents memory leaks).

Signed-off-by: Stephen Warren <swarren@nvidia.com>
drivers/usb/gadget/ci_udc.c

index 1428af85cffdb2644994ea2270e98eceeeb9f67a..435a2720e96fe506d409e29b5e593c1ab3242ddb 100644 (file)
@@ -875,5 +875,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 {
+       udc_disconnect();
+
+       ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
+       free(controller.items_mem);
+       free(controller.epts);
+
        return 0;
 }