Skip to content

Commit

Permalink
USB: correct locking in gadgetfs_disconnect
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Milan Svoboda authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent 17efe15 commit 07cb7f2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 07cb7f2

Please sign in to comment.