All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch]race between disconnect and open in usbtouchscreen
@ 2009-11-20 21:13 Oliver Neukum
  2009-11-20 21:22 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2009-11-20 21:13 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-input-u79uwXL29TY76Z2rM5mHXA, Ondrej Zary, Jiri Kosina,
	Daniel Ritz, Dmitry Torokhov

Hi,

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

	Regards
		Oliver

Signed-off-by: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>

--

commit e15f9b41115356ca5399f77bbc6b364c41b7f780
Author: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
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

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 68ece58..6850b0d 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch]race between disconnect and open in usbtouchscreen
  2009-11-20 21:13 [patch]race between disconnect and open in usbtouchscreen Oliver Neukum
@ 2009-11-20 21:22 ` Dmitry Torokhov
  2009-11-20 21:49   ` Oliver Neukum
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2009-11-20 21:22 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: linux-usb, linux-input, Ondrej Zary, Jiri Kosina, Daniel Ritz

Hi Oliver,

On Fri, Nov 20, 2009 at 10:13:47PM +0100, Oliver Neukum wrote:
> 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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch]race between disconnect and open in usbtouchscreen
  2009-11-20 21:22 ` Dmitry Torokhov
@ 2009-11-20 21:49   ` Oliver Neukum
  2009-11-23 17:21     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2009-11-20 21:49 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-usb, linux-input, Ondrej Zary, Jiri Kosina, Daniel Ritz

Am Freitag, 20. November 2009 22:22:59 schrieb Dmitry Torokhov:
> Hi Oliver,
> 
> On Fri, Nov 20, 2009 at 10:13:47PM +0100, Oliver Neukum wrote:
> > 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.

Signed-off-by: Oliver Neukum <oliver@neukum.org>

	Regards
		Oliver

--

commit 2705666144b8c898283974efc59fd5182e13e652
Author: Oliver Neukum <oliver@neukum.org>
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

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 68ece58..eddb628 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch]race between disconnect and open in usbtouchscreen
  2009-11-20 21:49   ` Oliver Neukum
@ 2009-11-23 17:21     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2009-11-23 17:21 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: linux-usb, linux-input, Ondrej Zary, Jiri Kosina, Daniel Ritz

On Fri, Nov 20, 2009 at 10:49:56PM +0100, Oliver Neukum wrote:
> Am Freitag, 20. November 2009 22:22:59 schrieb Dmitry Torokhov:
> > Hi Oliver,
> > 
> > On Fri, Nov 20, 2009 at 10:13:47PM +0100, Oliver Neukum wrote:
> > > 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.
> 

Applied, thank you Oliver.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-23 17:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20 21:13 [patch]race between disconnect and open in usbtouchscreen Oliver Neukum
2009-11-20 21:22 ` Dmitry Torokhov
2009-11-20 21:49   ` Oliver Neukum
2009-11-23 17:21     ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.