]> err.no Git - linux-2.6/commitdiff
USB: correct locking in gadgetfs_disconnect
authorMilan Svoboda <msvoboda@ra.rockwell.com>
Mon, 26 Jun 2006 14:46:00 +0000 (07:46 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 27 Sep 2006 18:58:52 +0000 (11:58 -0700)
This patch moves spin_lock (&dev->lock) before first use of dev.
I think that test to the state of device should be protected with
this spin_lock...

Signed-off-by: Milan Svoboda <msvoboda@ra.rockwell.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/inode.c

index 2a7162d897994e631a96e49c91751eb968ca705f..da85732fa993b63412be7f2ed63ef8b056719243 100644 (file)
@@ -1696,16 +1696,17 @@ gadgetfs_disconnect (struct usb_gadget *gadget)
 {
        struct dev_data         *dev = get_gadget_data (gadget);
 
+       spin_lock (&dev->lock);
        if (dev->state == STATE_UNCONNECTED) {
                DBG (dev, "already unconnected\n");
-               return;
+               goto exit;
        }
        dev->state = STATE_UNCONNECTED;
 
        INFO (dev, "disconnected\n");
-       spin_lock (&dev->lock);
        next_event (dev, GADGETFS_DISCONNECT);
        ep0_readable (dev);
+exit:
        spin_unlock (&dev->lock);
 }