Skip to content

Commit c468a8a

Browse files
oneukumgregkh
authored andcommitted
usb: iowarrior: fix deadlock on disconnect
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 2ca359f commit c468a8a

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
@@ -866,19 +866,20 @@ static void iowarrior_disconnect(struct usb_interface *interface)
866866
dev = usb_get_intfdata(interface);
867867
mutex_lock(&iowarrior_open_disc_lock);
868868
usb_set_intfdata(interface, NULL);
869+
/* prevent device read, write and ioctl */
870+
dev->present = 0;
869871

870872
minor = dev->minor;
873+
mutex_unlock(&iowarrior_open_disc_lock);
874+
/* give back our minor - this will call close() locks need to be dropped at this point*/
871875

872-
/* give back our minor */
873876
usb_deregister_dev(interface, &iowarrior_class);
874877

875878
mutex_lock(&dev->mutex);
876879

877880
/* prevent device read, write and ioctl */
878-
dev->present = 0;
879881

880882
mutex_unlock(&dev->mutex);
881-
mutex_unlock(&iowarrior_open_disc_lock);
882883

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

0 commit comments

Comments
 (0)