usb: gadget: atmel_usba: fix crashed during stopping when DEBUG is enabled
authorGregory CLEMENT <[email protected]>
Mon, 3 Mar 2014 16:48:34 +0000 (17:48 +0100)
committerFelipe Balbi <[email protected]>
Wed, 5 Mar 2014 20:40:10 +0000 (14:40 -0600)
commit 511f3c5 (usb: gadget: udc-core: fix a regression during gadget driver
unbinding) introduced a crash when DEBUG is enabled.

The debug trace in the atmel_usba_stop function made the assumption that the
driver pointer passed in parameter was not NULL, but since the commit above,
such assumption was no longer always true.

This commit now uses the driver pointer stored in udc which fixes this
issue.

[email protected] : improved commit log a bit ]

Cc: <[email protected]> # v3.2+
Acked-by: Alexandre Belloni <[email protected]>
Signed-off-by: Gregory CLEMENT <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
drivers/usb/gadget/atmel_usba_udc.c

index e57991edcf6757049cc383d38b8e45f695608c73..9f65324f9ae0c94471f284bcb8a66e49e420f486 100644 (file)
@@ -1827,12 +1827,12 @@ static int atmel_usba_stop(struct usb_gadget *gadget,
        toggle_bias(0);
        usba_writel(udc, CTRL, USBA_DISABLE_MASK);
 
-       udc->driver = NULL;
-
        clk_disable_unprepare(udc->hclk);
        clk_disable_unprepare(udc->pclk);
 
-       DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name);
+       DBG(DBG_GADGET, "unregistered driver `%s'\n", udc->driver->driver.name);
+
+       udc->driver = NULL;
 
        return 0;
 }