提交 52a74999 编写于 作者: G Greg Kroah-Hartman

Revert "USB: usb-skeleton.c: fix open/disconnect race"

This reverts commit 26c71a79.

It's not needed, to quote Ming Lei:
	Looks you have queued the patch into your tree, but just now I
	find the patch is not needed at all, since we have had
	minor_rwsem(drivers/usb/core/file.c) for this purpose, please
	drop the patch, sorry for it.

Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 d1620ca9
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#define USB_SKEL_VENDOR_ID 0xfff0 #define USB_SKEL_VENDOR_ID 0xfff0
#define USB_SKEL_PRODUCT_ID 0xfff0 #define USB_SKEL_PRODUCT_ID 0xfff0
static DEFINE_MUTEX(skel_mutex);
/* table of devices that work with this driver */ /* table of devices that work with this driver */
static const struct usb_device_id skel_table[] = { static const struct usb_device_id skel_table[] = {
{ USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
...@@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file) ...@@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file)
goto exit; goto exit;
} }
mutex_lock(&skel_mutex);
dev = usb_get_intfdata(interface); dev = usb_get_intfdata(interface);
if (!dev) { if (!dev) {
mutex_unlock(&skel_mutex);
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
} }
/* increment our usage count for the device */ /* increment our usage count for the device */
kref_get(&dev->kref); kref_get(&dev->kref);
mutex_unlock(&skel_mutex);
/* lock the device to allow correctly handling errors /* lock the device to allow correctly handling errors
* in resumption */ * in resumption */
mutex_lock(&dev->io_mutex); mutex_lock(&dev->io_mutex);
if (!dev->interface) {
retval = -ENODEV;
goto out_err;
}
retval = usb_autopm_get_interface(interface); retval = usb_autopm_get_interface(interface);
if (retval) if (retval)
...@@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file) ...@@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file)
/* save our object in the file's private structure */ /* save our object in the file's private structure */
file->private_data = dev; file->private_data = dev;
out_err:
mutex_unlock(&dev->io_mutex); mutex_unlock(&dev->io_mutex);
if (retval)
kref_put(&dev->kref, skel_delete);
exit: exit:
return retval; return retval;
...@@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface) ...@@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface)
int minor = interface->minor; int minor = interface->minor;
dev = usb_get_intfdata(interface); dev = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
/* give back our minor */ /* give back our minor */
usb_deregister_dev(interface, &skel_class); usb_deregister_dev(interface, &skel_class);
...@@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface) ...@@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface)
usb_kill_anchored_urbs(&dev->submitted); usb_kill_anchored_urbs(&dev->submitted);
mutex_lock(&skel_mutex);
usb_set_intfdata(interface, NULL);
/* decrement our usage count */ /* decrement our usage count */
kref_put(&dev->kref, skel_delete); kref_put(&dev->kref, skel_delete);
mutex_unlock(&skel_mutex);
dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册