Skip to content

Commit 7c5b971

Browse files
jhovoldgregkh
authored andcommitted
USB: iowarrior: drop redundant disconnect mutex
Drop the redundant disconnect mutex which was introduced after the open-disconnect race had been addressed generally in USB core by commit d4ead16 ("USB: prevent char device open/deregister race"). Specifically, the rw-semaphore in core guarantees that all calls to open() will have completed and that no new calls to open() will occur after usb_deregister_dev() returns. Hence there is no need use the driver data as an inverted disconnected flag. Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b5f8d46 commit 7c5b971

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

drivers/usb/misc/iowarrior.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ MODULE_LICENSE("GPL");
5858
static DEFINE_MUTEX(iowarrior_mutex);
5959

6060
static struct usb_driver iowarrior_driver;
61-
static DEFINE_MUTEX(iowarrior_open_disc_lock);
6261

6362
/*--------------*/
6463
/* data */
@@ -601,16 +600,13 @@ static int iowarrior_open(struct inode *inode, struct file *file)
601600
return -ENODEV;
602601
}
603602

604-
mutex_lock(&iowarrior_open_disc_lock);
605603
dev = usb_get_intfdata(interface);
606604
if (!dev) {
607-
mutex_unlock(&iowarrior_open_disc_lock);
608605
mutex_unlock(&iowarrior_mutex);
609606
return -ENODEV;
610607
}
611608

612609
mutex_lock(&dev->mutex);
613-
mutex_unlock(&iowarrior_open_disc_lock);
614610

615611
/* Only one process can open each device, no sharing. */
616612
if (dev->opened) {
@@ -842,7 +838,6 @@ static int iowarrior_probe(struct usb_interface *interface,
842838
if (retval) {
843839
/* something prevented us from registering this driver */
844840
dev_err(&interface->dev, "Not able to get a minor for this device.\n");
845-
usb_set_intfdata(interface, NULL);
846841
goto error;
847842
}
848843

@@ -866,16 +861,8 @@ static int iowarrior_probe(struct usb_interface *interface,
866861
*/
867862
static void iowarrior_disconnect(struct usb_interface *interface)
868863
{
869-
struct iowarrior *dev;
870-
int minor;
871-
872-
dev = usb_get_intfdata(interface);
873-
mutex_lock(&iowarrior_open_disc_lock);
874-
usb_set_intfdata(interface, NULL);
875-
876-
minor = dev->minor;
877-
mutex_unlock(&iowarrior_open_disc_lock);
878-
/* give back our minor - this will call close() locks need to be dropped at this point*/
864+
struct iowarrior *dev = usb_get_intfdata(interface);
865+
int minor = dev->minor;
879866

880867
usb_deregister_dev(interface, &iowarrior_class);
881868

0 commit comments

Comments
 (0)