From 943c441948581bd01ab196a4d32da88bfa0f13ce Mon Sep 17 00:00:00 2001 From: Wojtek Kaniewski Date: Fri, 8 Dec 2006 03:23:00 -0800 Subject: [PATCH] USB: at91_udc: Cleanup variables after failure in usb_gadget_register_driver() 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 Acked-by: David Brownell Cc: Andrew Victor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/at91_udc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 38a2e113e7..1926d39e48 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -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; } -- 2.39.5