netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]race between open and disconnect in irda-usb
@ 2007-10-11 15:45 Oliver Neukum
  2007-10-11 16:23 ` Jean Tourrilhes
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2007-10-11 15:45 UTC (permalink / raw)
  To: Jean Tourrilhes, Nick Fedchik, netdev, USB development list

Hi,

it seems to me that irda_usb_net_open() must set self->netopen
under spinlock or disconnect() may fail to kill all URBs.

Signed-off-by: Oliver Neukum <oneukum@suse.de>

	Regards
		Oliver

----

--- a/drivers/net/irda/irda-usb.c	2007-10-11 17:24:35.000000000 +0200
+++ b/drivers/net/irda/irda-usb.c	2007-10-11 17:30:30.000000000 +0200
@@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct 
 static int irda_usb_net_open(struct net_device *netdev)
 {
 	struct irda_usb_cb *self;
+	unsigned long flags;
 	char	hwname[16];
 	int i;
 	
@@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_
 	self = (struct irda_usb_cb *) netdev->priv;
 	IRDA_ASSERT(self != NULL, return -1;);
 
+	spin_lock_irqsave(&self->lock, flags);
 	/* Can only open the device if it's there */
 	if(!self->present) {
+		spin_unlock_irqrestore(&self->lock, flags);
 		IRDA_WARNING("%s(), device not present!\n", __FUNCTION__);
 		return -1;
 	}
 
 	if(self->needspatch) {
+		spin_unlock_irqrestore(&self->lock, flags);
 		IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
 		return -EIO ;
 	}
@@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_
 	/* To do *before* submitting Rx urbs and starting net Tx queue
 	 * Jean II */
 	self->netopen = 1;
+	spin_unlock_irqrestore(&self->lock, flags);
 
 	/* 
 	 * Now that everything should be initialized properly,


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

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

* Re: [PATCH]race between open and disconnect in irda-usb
  2007-10-11 15:45 Oliver Neukum
@ 2007-10-11 16:23 ` Jean Tourrilhes
  0 siblings, 0 replies; 4+ messages in thread
From: Jean Tourrilhes @ 2007-10-11 16:23 UTC (permalink / raw)
  To: Oliver Neukum, Samuel Ortiz; +Cc: Nick Fedchik, netdev, USB development list

On Thu, Oct 11, 2007 at 05:45:28PM +0200, Oliver Neukum wrote:
> Hi,
> 

	Hi,

	You need to cc Samuel Ortiz and the IrDA mailing list if you
want any meaningful response.

> it seems to me that irda_usb_net_open() must set self->netopen
> under spinlock or disconnect() may fail to kill all URBs.

	I believe to patch is correct, but in practice I fail to see
how it could happen. Anyway, Samuel will have the final word.

> Signed-off-by: Oliver Neukum <oneukum@suse.de>
> 
> 	Regards
> 		Oliver

	Have fun...

	Jean

> ----
> 
> --- a/drivers/net/irda/irda-usb.c	2007-10-11 17:24:35.000000000 +0200
> +++ b/drivers/net/irda/irda-usb.c	2007-10-11 17:30:30.000000000 +0200
> @@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct 
>  static int irda_usb_net_open(struct net_device *netdev)
>  {
>  	struct irda_usb_cb *self;
> +	unsigned long flags;
>  	char	hwname[16];
>  	int i;
>  	
> @@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_
>  	self = (struct irda_usb_cb *) netdev->priv;
>  	IRDA_ASSERT(self != NULL, return -1;);
>  
> +	spin_lock_irqsave(&self->lock, flags);
>  	/* Can only open the device if it's there */
>  	if(!self->present) {
> +		spin_unlock_irqrestore(&self->lock, flags);
>  		IRDA_WARNING("%s(), device not present!\n", __FUNCTION__);
>  		return -1;
>  	}
>  
>  	if(self->needspatch) {
> +		spin_unlock_irqrestore(&self->lock, flags);
>  		IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
>  		return -EIO ;
>  	}
> @@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_
>  	/* To do *before* submitting Rx urbs and starting net Tx queue
>  	 * Jean II */
>  	self->netopen = 1;
> +	spin_unlock_irqrestore(&self->lock, flags);
>  
>  	/* 
>  	 * Now that everything should be initialized properly,
> 

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

* [PATCH]race between open and disconnect in irda-usb
@ 2007-10-12  8:53 Oliver Neukum
       [not found] ` <200710121053.55829.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2007-10-12  8:53 UTC (permalink / raw)
  To: Jean Tourrilhes, Nick Fedchik, netdev, USB development list,
	Samuel Ortiz

Hi,

it seems to me that irda_usb_net_open() must set self->netopen
under spinlock or disconnect() may fail to kill all URBs, if it is called
while an interface is opened.

Signed-off-by: Oliver Neukum <oneukum@suse.de>

	Regards
		Oliver

----

--- a/drivers/net/irda/irda-usb.c	2007-10-11 17:24:35.000000000 +0200
+++ b/drivers/net/irda/irda-usb.c	2007-10-11 17:30:30.000000000 +0200
@@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct 
 static int irda_usb_net_open(struct net_device *netdev)
 {
 	struct irda_usb_cb *self;
+	unsigned long flags;
 	char	hwname[16];
 	int i;
 	
@@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_
 	self = (struct irda_usb_cb *) netdev->priv;
 	IRDA_ASSERT(self != NULL, return -1;);
 
+	spin_lock_irqsave(&self->lock, flags);
 	/* Can only open the device if it's there */
 	if(!self->present) {
+		spin_unlock_irqrestore(&self->lock, flags);
 		IRDA_WARNING("%s(), device not present!\n", __FUNCTION__);
 		return -1;
 	}
 
 	if(self->needspatch) {
+		spin_unlock_irqrestore(&self->lock, flags);
 		IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
 		return -EIO ;
 	}
@@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_
 	/* To do *before* submitting Rx urbs and starting net Tx queue
 	 * Jean II */
 	self->netopen = 1;
+	spin_unlock_irqrestore(&self->lock, flags);
 
 	/* 
 	 * Now that everything should be initialized properly,


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

* Re: [PATCH]race between open and disconnect in irda-usb
       [not found] ` <200710121053.55829.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2007-10-13  0:32   ` Samuel Ortiz
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2007-10-13  0:32 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Jean Tourrilhes, Nick Fedchik,
	irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, USB development list,
	netdev-u79uwXL29TY76Z2rM5mHXA

Hi Oliver,

On Fri, Oct 12, 2007 at 10:53:55AM +0200, Oliver Neukum wrote:
> Hi,
> 
> it seems to me that irda_usb_net_open() must set self->netopen
> under spinlock or disconnect() may fail to kill all URBs, if it is called
> while an interface is opened.
Makes sense, yes.
I will push it upstream with my next IrDA update.

Cheers,
Samuel.


> Signed-off-by: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
> 
> 	Regards
> 		Oliver
> 
> ----
> 
> --- a/drivers/net/irda/irda-usb.c	2007-10-11 17:24:35.000000000 +0200
> +++ b/drivers/net/irda/irda-usb.c	2007-10-11 17:30:30.000000000 +0200
> @@ -1168,6 +1168,7 @@ static int stir421x_patch_device(struct 
>  static int irda_usb_net_open(struct net_device *netdev)
>  {
>  	struct irda_usb_cb *self;
> +	unsigned long flags;
>  	char	hwname[16];
>  	int i;
>  	
> @@ -1177,13 +1178,16 @@ static int irda_usb_net_open(struct net_
>  	self = (struct irda_usb_cb *) netdev->priv;
>  	IRDA_ASSERT(self != NULL, return -1;);
>  
> +	spin_lock_irqsave(&self->lock, flags);
>  	/* Can only open the device if it's there */
>  	if(!self->present) {
> +		spin_unlock_irqrestore(&self->lock, flags);
>  		IRDA_WARNING("%s(), device not present!\n", __FUNCTION__);
>  		return -1;
>  	}
>  
>  	if(self->needspatch) {
> +		spin_unlock_irqrestore(&self->lock, flags);
>  		IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ;
>  		return -EIO ;
>  	}
> @@ -1198,6 +1202,7 @@ static int irda_usb_net_open(struct net_
>  	/* To do *before* submitting Rx urbs and starting net Tx queue
>  	 * Jean II */
>  	self->netopen = 1;
> +	spin_unlock_irqrestore(&self->lock, flags);
>  
>  	/* 
>  	 * Now that everything should be initialized properly,
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> irda-users mailing list
> irda-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> http://lists.sourceforge.net/lists/listinfo/irda-users


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

end of thread, other threads:[~2007-10-13  0:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12  8:53 [PATCH]race between open and disconnect in irda-usb Oliver Neukum
     [not found] ` <200710121053.55829.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2007-10-13  0:32   ` Samuel Ortiz
  -- strict thread matches above, loose matches on Subject: below --
2007-10-11 15:45 Oliver Neukum
2007-10-11 16:23 ` Jean Tourrilhes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).