aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/inode.c
diff options
context:
space:
mode:
authorMilan Svoboda <msvoboda@ra.rockwell.com>2006-06-26 10:46:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:52 -0400
commit07cb7f23d07aa4d197dbeb123eb9719c176190ee (patch)
tree9cecc8aa069b5ed1550106dab1aab5e6c42eefc7 /drivers/usb/gadget/inode.c
parent17efe155253e3f81caa6cc57ec2af1c128618698 (diff)
USB: correct locking in gadgetfs_disconnect
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>
Diffstat (limited to 'drivers/usb/gadget/inode.c')
-rw-r--r--drivers/usb/gadget/inode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 2a7162d89799..da85732fa993 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1696,16 +1696,17 @@ gadgetfs_disconnect (struct usb_gadget *gadget)
1696{ 1696{
1697 struct dev_data *dev = get_gadget_data (gadget); 1697 struct dev_data *dev = get_gadget_data (gadget);
1698 1698
1699 spin_lock (&dev->lock);
1699 if (dev->state == STATE_UNCONNECTED) { 1700 if (dev->state == STATE_UNCONNECTED) {
1700 DBG (dev, "already unconnected\n"); 1701 DBG (dev, "already unconnected\n");
1701 return; 1702 goto exit;
1702 } 1703 }
1703 dev->state = STATE_UNCONNECTED; 1704 dev->state = STATE_UNCONNECTED;
1704 1705
1705 INFO (dev, "disconnected\n"); 1706 INFO (dev, "disconnected\n");
1706 spin_lock (&dev->lock);
1707 next_event (dev, GADGETFS_DISCONNECT); 1707 next_event (dev, GADGETFS_DISCONNECT);
1708 ep0_readable (dev); 1708 ep0_readable (dev);
1709exit:
1709 spin_unlock (&dev->lock); 1710 spin_unlock (&dev->lock);
1710} 1711}
1711 1712