提交 07cb7f23 编写于 作者: M Milan Svoboda 提交者: 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: NMilan Svoboda <msvoboda@ra.rockwell.com>
Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 17efe155
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册