USB: race on disconnect in mdc800
authorOliver Neukum <oliver@neukum.org>
Fri, 5 Jan 2007 16:42:35 +0000 (17:42 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 7 Feb 2007 23:44:34 +0000 (15:44 -0800)
I overlooked one. Setting the flag and killing the URBs must be under the lock
so that no URB is submitted after usb_kill_urb()

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/image/mdc800.c

index 63a84bb..d308afd 100644 (file)
@@ -565,11 +565,15 @@ static void mdc800_usb_disconnect (struct usb_interface *intf)
 
                usb_deregister_dev(intf, &mdc800_class);
 
+               /* must be under lock to make sure no URB
+                  is submitted after usb_kill_urb() */
+               mutex_lock(&mdc800->io_lock);
                mdc800->state=NOT_CONNECTED;
 
                usb_kill_urb(mdc800->irq_urb);
                usb_kill_urb(mdc800->write_urb);
                usb_kill_urb(mdc800->download_urb);
+               mutex_unlock(&mdc800->io_lock);
 
                mdc800->dev = NULL;
                usb_set_intfdata(intf, NULL);