Skip to content

Commit b5454da

Browse files
oneukumgregkh
authored andcommitted
usb: iowarrior: fix deadlock on disconnect
commit c468a8a upstream. We have to drop the mutex before we close() upon disconnect() as close() needs the lock. This is safe to do by dropping the mutex as intfdata is already set to NULL, so open() will fail. Fixes: 03f36e8 ("USB: open disconnect race in iowarrior") Reported-by: [email protected] Cc: stable <[email protected]> Signed-off-by: Oliver Neukum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 44db85e commit b5454da

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/misc/iowarrior.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,19 +870,20 @@ static void iowarrior_disconnect(struct usb_interface *interface)
870870
dev = usb_get_intfdata(interface);
871871
mutex_lock(&iowarrior_open_disc_lock);
872872
usb_set_intfdata(interface, NULL);
873+
/* prevent device read, write and ioctl */
874+
dev->present = 0;
873875

874876
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*/
875879

876-
/* give back our minor */
877880
usb_deregister_dev(interface, &iowarrior_class);
878881

879882
mutex_lock(&dev->mutex);
880883

881884
/* prevent device read, write and ioctl */
882-
dev->present = 0;
883885

884886
mutex_unlock(&dev->mutex);
885-
mutex_unlock(&iowarrior_open_disc_lock);
886887

887888
if (dev->opened) {
888889
/* There is a process that holds a filedescriptor to the device ,

0 commit comments

Comments
 (0)