orinoco: Clear dangling pointer on hardware busy
PATCH RESEND 1/1 orinoco: Clear dangling pointer on hardware busy
On hardware busy the scan request pointer should be cleared, as higher levels will release. This avoids a crash when that pointer is erroneously used later.
---
When the hardware is busy the error is propagated to higher levels on the stack. Those layers release the buffer. Therefore the copy of the pointer must be erased. Otherwise subsequent events checking this pointer ma crash.
---
drivers/net/wireless/orinoco/cfg.c +9 -0
@@ -151,8 +151,17 @@ static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev,return -EBUSY ; priv->scan_request = request; +DEBUG (3 ,"orinoco_scan():" +" scan_request %p wiphy %p, dev %p\n" , + priv->scan_request, + priv->scan_request->wiphy, + priv->scan_request->dev + ); err =orinoco_hw_trigger_scan (priv, request->ssids); +/* On EBUSY the hardware is busy. We aren't processing the request */ +if (err == -EBUSY ) + priv->scan_request =NULL ;return err; }
drivers/net/wireless/orinoco/scan.c +12 -0
@@ -230,6 +230,12 @@ void orinoco_add_hostscan_results(struct orinoco_private *priv, scan_abort:if (priv->scan_request) { +DEBUG (3 ,"orinoco_add_hostscan_results():" +" scan_request %p wiphy %p, dev %p\n" , + priv->scan_request, + priv->scan_request->wiphy, + priv->scan_request->dev + );cfg80211_scan_done (priv->scan_request, abort); priv->scan_request =NULL ; }
@@ -238,6 +244,12 @@ void orinoco_add_hostscan_results(struct orinoco_private *priv,void orinoco_scan_done (struct orinoco_private *priv,bool abort) {if (priv->scan_request) { +DEBUG (3 ,"orinoco_scan_done():" +" scan_request %p, wiphy %p, dev %p\n" , + priv->scan_request, + priv->scan_request->wiphy, + priv->scan_request->dev + );cfg80211_scan_done (priv->scan_request, abort); priv->scan_request =NULL ; }
Quoted 1 line · On 21/03/2011 08:21, [email protected] wrote:
On hardware busy the scan request pointer should be cleared, as higher levels will release. This avoids a crash when that pointer is erroneously used later.
I think you need to add line breaks for the git log
Quoted 12 lines
Signed-off-by Joseph J. Gunn<[email protected]>---
When the hardware is busy the error is propagated to higher levels on the stack. Those layers release the buffer. Therefore the copy of the pointer must be erased. Otherwise subsequent events checking this pointer ma crash.
---drivers/net/wireless/orinoco/cfg.c +0
-0@@ -151,8 +151,17 @@ static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev,return -EBUSY ; priv->scan_request = request;
drivers/net/wireless/orinoco/cfg.c static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev, · line 163
Quoted 10 lines
drivers/net/wireless/orinoco/cfg.c +8
-0+DEBUG (3 ,"orinoco_scan():" +" scan_request %p wiphy %p, dev %p\n" , + priv->scan_request, + priv->scan_request->wiphy, + priv->scan_request->dev + ); err =orinoco_hw_trigger_scan (priv, request->ssids); +/* On EBUSY the hardware is busy. We aren't processing the request */ +if (err == -EBUSY )
We should reset priv->scan_request on all errors, not just -EBUSY. Were you getting this in a particular situation? If so, highlighting it in the commit log is useful.
I notice -EBUSY is returned when we can't get the orinoco_lock - are you having an issue with lock cotention on a particular device?
Quoted 9 lines
drivers/net/wireless/orinoco/cfg.c +1
-0+ priv->scan_request =NULL ;return err; }drivers/net/wireless/orinoco/scan.c +0
-0
drivers/net/wireless/orinoco/scan.c void orinoco_add_hostscan_results(struct orinoco_private *priv, · line 238
Quoted 9 lines
drivers/net/wireless/orinoco/scan.c +6
-0@@ -230,6 +230,12 @@ void orinoco_add_hostscan_results(struct orinoco_private *priv, scan_abort:if (priv->scan_request) { +DEBUG (3 ,"orinoco_add_hostscan_results():" +" scan_request %p wiphy %p, dev %p\n" , + priv->scan_request, + priv->scan_request->wiphy, + priv->scan_request->dev + );
I'm not a big fan of scattering DEBUG statements about, but if we're going to, use __FUNCTION__ (or whatever the C99 incarnation is) rather than explicitly naming the functions.
Dave.
Thanks for your response(s).
Quoted 7 lines · Dave Kilroy
From: Dave Kilroy <[email protected]>
Subject: Re: [Orinoco-devel] [PATCH 2.6.38-rc8-wl RESEND] orinoco: Clear dangling pointer on hardware busy
To: [email protected]
Cc: [email protected], [email protected]
Date: Monday, March 21, 2011, 6:40 PM
On 21/03/2011 08:21, [email protected]
wrote:
Quoted 6 lines
Quoted 1 line
On hardware busy the scan request pointer should be
cleared, as higher levels will release. This avoids a crash when that pointer is erroneously used later.
I think you need to add line breaks for the git log
Sorry i am new to this.
logs on git don't have a column length restriction. Is there a "80", or so, column restriction suggested for this?
Quoted 42 lines
Quoted 3 lines
Signed-off-by Joseph J. Gunn<[email protected]>---
When the hardware is busy the error is propagated tohigher levels on the stack. Those layers release the buffer. Therefore the copy of the pointer must be erased. Otherwise subsequent events checking this pointer ma crash.
Review
Quoted 2 lines
---
(quoted diff) +0
-0
b/drivers/net/wireless/orinoco/cfg.cdrivers/net/wireless/orinoco/cfg.c static int orinoco_scan(struct
Quoted 4 lines
index 09fae2f..2022815 100644
drivers/net/wireless/orinoco/cfg.c +0
-0@@ -151,8 +151,17 @@ static int orinoco_scan(structwiphy *wiphy, struct
net_device*dev,Quoted 1 line
return
-EBUSY;Quoted 2 lines
priv->scan_request= request;Quoted 2 lines
+ DEBUG(3, "
orinoco_scan():"
+ "scan_request%p wiphy %p, dev %p\n",
Quoted 1 line
+
priv->scan_request,Quoted 1 line
+
priv->scan_request->wiphy,Quoted 1 line
+
priv->scan_request->devQuoted 3 lines
+ );
err =
orinoco_hw_trigger_scan(priv, request->ssids);Quoted 1 line
+ /* On EBUSY the hardware is busy.
We aren't processing the request */
Quoted 1 line
+ if (err ==
-EBUSY)We should reset
priv->scan_requeston all errors, not just-EBUSY. Were
you getting this in a particular situation? If so, highlighting it in
the commit log is useful.
Quoted 4 lines
I notice
-EBUSYis returned when we can't get theorinoco_lock- are you
having an issue with lock cotention on a particular device?
The calls for orinoco_lock seem to be well placed from a software point.
There are other cases where the low level hardware routines return EBUSY. When the hardware can not accept the command. This is the situation i can reproduce.
It is possible, probable even, that all cases of error do not propagate the scan request. I don't know the driver that well yet.
I chose to limit the effect of the patch to the case i could prove.
Quoted 27 lines
Quoted 2 lines
+
priv->scan_request= NULL;Review
Quoted 4 lines
return err;
}(quoted diff) +0
-0
b/drivers/net/wireless/orinoco/scan.cdrivers/net/wireless/orinoco/scan.c void
Quoted 4 lines
index e99ca1c..698e9ff 100644
drivers/net/wireless/orinoco/scan.c +0
-0@@ -230,6 +230,12 @@ voidorinoco_add_hostscan_results(struct
orinoco_private*priv,Quoted 3 lines
scan_abort:
if(
priv->scan_request) {Quoted 1 line
+ DEBUG(3,
"
orinoco_add_hostscan_results():"Quoted 1 line
+
"
scan_request%p wiphy %p, dev %p\n",Quoted 1 line
+
priv->scan_request,Quoted 1 line
+
priv->scan_request->wiphy,Quoted 1 line
+
priv->scan_request->dev
Quoted 9 lines
Quoted 1 line
+
);
I'm not a big fan of scattering DEBUG statements about, but if we're
going to, use__FUNCTION__(or whatever the C99 incarnation is) rather
than explicitly naming the functions.
As per the above the patch only fixes one possible scenario. I left the
messages there because they could be used to help prove/disprove that another set of events could produce a similar error.
It appears that some recent changes in user space code make it more likely for the driver to hit this condition.
Quoted 4 lines
Dave.
Thanks
Joe
Quoted 5 lines · Joe Gunn
Quoted 1 line
I think you need to add line breaks for the git log
Sorry i am new to this. logs on git don't have a column length restriction. Is there a "80", or so, column restriction suggested for this?
I think following an old rule from usenet, max 72 chars per line, is still valid. At least replies still look nice.
Signature · 1 line
Kalle Valo