linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan()
@ 2011-06-29 20:13 Jesper Juhl
  2011-06-29 20:27 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2011-06-29 20:13 UTC (permalink / raw)
  To: linux-wireless
  Cc: netdev, linux-kernel, David S. Miller, John W. Linville,
	Johannes Berg

If the 'driver_initiated' function argument to
__cfg80211_stop_sched_scan() is not 0 then we'll return an
uninitialized 'ret' from the function.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/wireless/scan.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 7a6c676..7940fa5 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -132,7 +132,7 @@ EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
 			       bool driver_initiated)
 {
-	int err;
+	int err = 0;
 	struct net_device *dev;
 
 	ASSERT_RDEV_LOCK(rdev);
-- 
1.7.5.2


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan()
  2011-06-29 20:13 [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan() Jesper Juhl
@ 2011-06-29 20:27 ` Johannes Berg
  2011-06-29 20:33   ` Luciano Coelho
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2011-06-29 20:27 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-wireless, netdev, linux-kernel, David S. Miller,
	John W. Linville, Luciano Coelho

On Wed, 2011-06-29 at 22:13 +0200, Jesper Juhl wrote:
> If the 'driver_initiated' function argument to
> __cfg80211_stop_sched_scan() is not 0 then we'll return an
> uninitialized 'ret' from the function.

'err'. I also dislike the initialisation, can we just replace the
"return err;" at the end of the function with "return 0;" instead?

Luca, should it maybe be return -ENOENT anyway in the !sched_scan_req
case?

johannes



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

* Re: [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan()
  2011-06-29 20:27 ` Johannes Berg
@ 2011-06-29 20:33   ` Luciano Coelho
  2011-06-29 20:42     ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: Luciano Coelho @ 2011-06-29 20:33 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Jesper Juhl, linux-wireless, netdev, linux-kernel,
	David S. Miller, John W. Linville

On Wed, 2011-06-29 at 22:27 +0200, Johannes Berg wrote: 
> On Wed, 2011-06-29 at 22:13 +0200, Jesper Juhl wrote:
> > If the 'driver_initiated' function argument to
> > __cfg80211_stop_sched_scan() is not 0 then we'll return an
> > uninitialized 'ret' from the function.
> 
> 'err'. I also dislike the initialisation, can we just replace the
> "return err;" at the end of the function with "return 0;" instead?

Luckily we were never using the return value when passing
driver_initiate =- false.

And I agree with you, there's no use to return err at the end.  Better
to simply return 0.


> Luca, should it maybe be return -ENOENT anyway in the !sched_scan_req
> case?

We could do that.  I had just thought that stopping a scan that is not
running would just be a NOP, but if you prefer to return an error in
that case, I can do it.

-- 
Cheers,
Luca.


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

* Re: [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan()
  2011-06-29 20:33   ` Luciano Coelho
@ 2011-06-29 20:42     ` Jesper Juhl
  2011-06-29 20:55       ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2011-06-29 20:42 UTC (permalink / raw)
  To: Luciano Coelho
  Cc: Johannes Berg, linux-wireless, netdev, linux-kernel,
	David S. Miller, John W. Linville

On Wed, 29 Jun 2011, Luciano Coelho wrote:

> On Wed, 2011-06-29 at 22:27 +0200, Johannes Berg wrote: 
> > On Wed, 2011-06-29 at 22:13 +0200, Jesper Juhl wrote:
> > > If the 'driver_initiated' function argument to
> > > __cfg80211_stop_sched_scan() is not 0 then we'll return an
> > > uninitialized 'ret' from the function.
> > 
> > 'err'. I also dislike the initialisation, can we just replace the
> > "return err;" at the end of the function with "return 0;" instead?
> 
> Luckily we were never using the return value when passing
> driver_initiate =- false.
> 
> And I agree with you, there's no use to return err at the end.  Better
> to simply return 0.
> 
Ok, so how about this?

>From 606ee120df85dbd5205996878f50e51b8b7cd4a3 Mon Sep 17 00:00:00 2001
From: Jesper Juhl <jj@chaosbits.net>
Date: Wed, 29 Jun 2011 22:49:33 +0200
Subject: [PATCH] net, wireless: Don't return uninitialized in
 __cfg80211_stop_sched_scan()

If the 'driver_initiated' function argument to
__cfg80211_stop_sched_scan() is not 0 then we'll return an
uninitialized 'err' from the function.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/wireless/scan.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 7a6c676..5d23503 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -132,7 +132,6 @@ EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
 			       bool driver_initiated)
 {
-	int err;
 	struct net_device *dev;
 
 	ASSERT_RDEV_LOCK(rdev);
@@ -143,7 +142,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
 	dev = rdev->sched_scan_req->dev;
 
 	if (!driver_initiated) {
-		err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev);
+		int err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev);
 		if (err)
 			return err;
 	}
@@ -153,7 +152,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
 	kfree(rdev->sched_scan_req);
 	rdev->sched_scan_req = NULL;
 
-	return err;
+	return 0;
 }
 
 static void bss_release(struct kref *ref)
-- 
1.7.6

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan()
  2011-06-29 20:42     ` Jesper Juhl
@ 2011-06-29 20:55       ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2011-06-29 20:55 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Luciano Coelho, linux-wireless, netdev, linux-kernel,
	David S. Miller, John W. Linville

On Wed, 2011-06-29 at 22:42 +0200, Jesper Juhl wrote:
> On Wed, 29 Jun 2011, Luciano Coelho wrote:
> 
> > On Wed, 2011-06-29 at 22:27 +0200, Johannes Berg wrote: 
> > > On Wed, 2011-06-29 at 22:13 +0200, Jesper Juhl wrote:
> > > > If the 'driver_initiated' function argument to
> > > > __cfg80211_stop_sched_scan() is not 0 then we'll return an
> > > > uninitialized 'ret' from the function.
> > > 
> > > 'err'. I also dislike the initialisation, can we just replace the
> > > "return err;" at the end of the function with "return 0;" instead?
> > 
> > Luckily we were never using the return value when passing
> > driver_initiate =- false.
> > 
> > And I agree with you, there's no use to return err at the end.  Better
> > to simply return 0.
> > 
> Ok, so how about this?

Fine with me.

johannes



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

end of thread, other threads:[~2011-06-29 20:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 20:13 [PATCH] net, wireless: Don't return uninitialized in __cfg80211_stop_sched_scan() Jesper Juhl
2011-06-29 20:27 ` Johannes Berg
2011-06-29 20:33   ` Luciano Coelho
2011-06-29 20:42     ` Jesper Juhl
2011-06-29 20:55       ` Johannes Berg

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).