From: Wojtek Kaniewski Date: Fri, 8 Dec 2006 11:23:00 +0000 (-0800) Subject: USB: at91_udc: Cleanup variables after failure in usb_gadget_register_driver() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=943c441948581bd01ab196a4d32da88bfa0f13ce;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 --- diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 38a2e113e705..1926d39e4801 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; }