Commit 07cb7f23 authored by Milan Svoboda's avatar Milan Svoboda Committed by Greg Kroah-Hartman

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: default avatarMilan Svoboda <msvoboda@ra.rockwell.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 17efe155
...@@ -1696,16 +1696,17 @@ gadgetfs_disconnect (struct usb_gadget *gadget) ...@@ -1696,16 +1696,17 @@ gadgetfs_disconnect (struct usb_gadget *gadget)
{ {
struct dev_data *dev = get_gadget_data (gadget); struct dev_data *dev = get_gadget_data (gadget);
spin_lock (&dev->lock);
if (dev->state == STATE_UNCONNECTED) { if (dev->state == STATE_UNCONNECTED) {
DBG (dev, "already unconnected\n"); DBG (dev, "already unconnected\n");
return; goto exit;
} }
dev->state = STATE_UNCONNECTED; dev->state = STATE_UNCONNECTED;
INFO (dev, "disconnected\n"); INFO (dev, "disconnected\n");
spin_lock (&dev->lock);
next_event (dev, GADGETFS_DISCONNECT); next_event (dev, GADGETFS_DISCONNECT);
ep0_readable (dev); ep0_readable (dev);
exit:
spin_unlock (&dev->lock); spin_unlock (&dev->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment