usb: gadget: atmel_usba: always test udc->driver
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Tue, 6 May 2014 15:16:07 +0000 (17:16 +0200)
committerFelipe Balbi <balbi@ti.com>
Wed, 14 May 2014 14:23:26 +0000 (09:23 -0500)
Found using smatch: drivers/usb/gadget/atmel_usba_udc.c:1689 usba_udc_irq()
error: we previously assumed 'udc->driver' could be null (see line 1636)

Always test udc->driver before using its members.

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/atmel_usba_udc.c

index 9f65324f9ae0c94471f284bcb8a66e49e420f486..76023ce449a39cd82db862719f7392d36b4deb57 100644 (file)
@@ -1686,7 +1686,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
                reset_all_endpoints(udc);
 
                if (udc->gadget.speed != USB_SPEED_UNKNOWN
-                               && udc->driver->disconnect) {
+                               && udc->driver && udc->driver->disconnect) {
                        udc->gadget.speed = USB_SPEED_UNKNOWN;
                        spin_unlock(&udc->lock);
                        udc->driver->disconnect(&udc->gadget);