Skip to contentSkip to conversation

race between disconnect and open in usbtouchscreen

PATCH Applied Oliver Neukum 3 participants 4 messages Nov 20, 2009 – Nov 23, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 race between disconnect and open in usbtouchscreen

Hi,

an open() between killing the urb and unregistering the device can lead to IO to a disconnected device.

Regards
Oliver

--

commit e15f9b41115356ca5399f77bbc6b364c41b7f780

Author: Oliver Neukum <[email protected]>
Date:   Fri Nov 20 21:50:38 2009 +0100

usbtouchscreen: fix race between open and disconnect

the input device must be unregistered before IO is stopped so that open cannot restart IO

drivers/input/touchscreen/usbtouchscreen.c +1 -1
index 68ece58..6850b0d 100644
@@ -1087,8 +1087,8 @@ static void usbtouch_disconnect(struct usb_interface *intf)
 
 	dbg("%s - usbtouch is initialized, cleaning up", __func__);
 	usb_set_intfdata(intf, NULL);
-	usb_kill_urb(usbtouch->irq);
 	input_unregister_device(usbtouch->input);
+	usb_kill_urb(usbtouch->irq);
 	usb_free_urb(usbtouch->irq);
 	usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
 	kfree(usbtouch);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#1 lore raw

Hi Oliver,

Quoted 5 lines · Oliver Neukum

Hi,

an open() between killing the urb and unregistering the device can lead to IO to a disconnected device.

usbtouch_close() calls usb_kill_urb() so there is no race. usb_kill_urb() simply not needed in usbtouch_disconnect().

Thanks.

Signature · 1 line
Dmitry
#2 lore raw

Am Freitag, 20. November 2009 22:22:59 schrieb Dmitry Torokhov:

Quoted 10 lines

Hi Oliver,

Quoted 4 lines · Oliver Neukum

Hi,

an open() between killing the urb and unregistering the device can lead to IO to a disconnected device.

usbtouch_close() calls usb_kill_urb() so there is no race. usb_kill_urb() simply not needed in usbtouch_disconnect().

Then it needs to go.

Regards
Oliver

--

commit 2705666144b8c898283974efc59fd5182e13e652

Author: Oliver Neukum <[email protected]>
Date:   Fri Nov 20 22:41:04 2009 +0100

usbtouchscreen:remove unneeded usb_kill_urb

usb_kill_urb() in disconnect is not needed as unregistering cause close to be called

drivers/input/touchscreen/usbtouchscreen.c +1 -1
index 68ece58..eddb628 100644
@@ -1087,7 +1087,7 @@ static void usbtouch_disconnect(struct usb_interface *intf)
 
 	dbg("%s - usbtouch is initialized, cleaning up", __func__);
 	usb_set_intfdata(intf, NULL);
-	usb_kill_urb(usbtouch->irq);
+	/* this will stop IO via close */
 	input_unregister_device(usbtouch->input);
 	usb_free_urb(usbtouch->irq);
 	usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
maintainer Applied
#3 lore raw
Quoted 6 lines · Oliver Neukum

Am Freitag, 20. November 2009 22:22:59 schrieb Dmitry Torokhov:

Quoted 5 lines

Hi Oliver,

Quoted 2 lines · Oliver Neukum

Hi,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

an open() between killing the urb and unregistering the device can lead to IO to a disconnected device.

usbtouch_close() calls usb_kill_urb() so there is no race. usb_kill_urb() simply not needed in usbtouch_disconnect().

Then it needs to go.

Applied, thank you Oliver.

Signature · 1 line
Dmitry