USB: at91_udc: Cleanup variables after failure in usb_gadget_register_driver()
authorWojtek Kaniewski <wojtekka@toxygen.net>
Fri, 8 Dec 2006 11:23:00 +0000 (03:23 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 20 Dec 2006 18:14:27 +0000 (10:14 -0800)
This patch zeroes some variables when usb_gadget_register_driver()
fails. gadgetfs does a dummy registration to get the name of the USB
driver and then waits for user-land driver. If someone plugs the cable
in the meantime, bad things happen, because at91_udc has been left in
inconsistent state.

Signed-off-by: Wojtek Kaniewski <wojtekka@toxygen.net>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/at91_udc.c

index 38a2e113e705069add08a8663bb400c8f48b0a49..1926d39e480144997486e6efbcaf71f7767948b1 100644 (file)
@@ -1601,6 +1601,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
        if (retval) {
                DBG("driver->bind() returned %d\n", retval);
                udc->driver = NULL;
+               udc->gadget.dev.driver = NULL;
+               udc->gadget.dev.driver_data = NULL;
+               udc->enabled = 0;
+               udc->selfpowered = 0;
                return retval;
        }