Skip to contentSkip to conversation

b43{,legacy}_start can return uninitialized value

PATCH In review Adrian Bunk 3 participants 6 messages Oct 14, 2007 – Oct 15, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

drivers/net/wireless/b43/main.c:b43_start() consists of the following code:

<-- snip -->

static int b43_start(struct ieee80211_hw *hw)

{
        struct b43_wl *wl = hw_to_b43_wl(hw);
        struct b43_wldev *dev = wl->current_dev;
        int did_init = 0;
        int err;

        mutex_lock(&wl->mutex);

        if (b43_status(dev) < B43_STAT_INITIALIZED) {
                err = b43_wireless_core_init(dev);
                if (err)
                        goto out_mutex_unlock;
                did_init = 1;
        }

        if (b43_status(dev) < B43_STAT_STARTED) {
                err = b43_wireless_core_start(dev);
                if (err) {
                        if (did_init)
                                b43_wireless_core_exit(dev);
                        goto out_mutex_unlock;
                }
        }

out_mutex_unlock:

        mutex_unlock(&wl->mutex);

        return err;
}

<-- snip -->

If (b43_status(dev) == B43_STAT_STARTED) this function returns the value of an uninitialized variable.

drivers/net/wireless/b43legacy/main.c:b43legacy_start() has the same issue.

Spotted by the Coverity checker.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#1 lore raw

PATCH 1/1 drivers/net/wireless/b43/main.c: fix an uninitialized variable

Fix an uninitialized variable in drivers/net/wireless/b43/main.c::b43_start().

From: Adrian Bunk <[email protected]>

---
 drivers/net/wireless/b43/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/b43/main.c +1 -1
Index: linux-2.6.23-mm1/drivers/net/wireless/b43/main.c
===================================================================
@@ -3495,7 +3495,7 @@ static int b43_start(struct ieee80211_hw
 	struct b43_wl *wl = hw_to_b43_wl(hw);
 	struct b43_wldev *dev = wl->current_dev;
 	int did_init = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&wl->mutex);
 
#2 lore raw

Re: [-mm Patch] drivers/net/wireless/b43/main.c: fix an uninitialized variable

Quoted 4 lines · WANG Cong

Fix an uninitialized variable in drivers/net/wireless/b43/main.c::b43_start().

From: Adrian Bunk <[email protected]>

A technical remark regarding these two patches:

These are your patches, not mine.

You can note formally or informally that I reported/forwarded these issues, but I'm neither in a legal sense the author of these patches nor am I in a technical sense responsible for their correctness [1], and a
From: tag is therefore not appropriate.

Quoted 11 lines
---
 drivers/net/wireless/b43/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.23-mm1/drivers/net/wireless/b43/main.c
===================================================================

drivers/net/wireless/b43/main.c static int b43_start(struct ieee80211_hw · line 3500

Quoted 7 lines
drivers/net/wireless/b43/main.c +1 -1
@@ -3495,7 +3495,7 @@ static int b43_start(struct ieee80211_hw
 	struct b43_wl *wl = hw_to_b43_wl(hw);
 	struct b43_wldev *dev = wl->current_dev;
 	int did_init = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&wl->mutex);

cu
Adrian

[1] they might or might not be correct (I don't know)

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw

Re: [-mm Patch] drivers/net/wireless/b43/main.c: fix an uninitialized variable

Quoted 5 lines · Adrian Bunk
Quoted 4 lines · WANG Cong

Fix an uninitialized variable in drivers/net/wireless/b43/main.c::b43_start().

From: Adrian Bunk <[email protected]>

Quoted 10 lines

A technical remark regarding these two patches:

These are your patches, not mine.

You can note formally or informally that I reported/forwarded these issues, but I'm neither in a legal sense the author of these patches nor am I in a technical sense responsible for their correctness [1], and a
From: tag is therefore not appropriate.

OK. I look through Jonathan's patch[1], but didn't find a proper tag as you suggested. I think the "Reported-by:" tag may be appropriate, as the above.

So, we need a "Reported-by:" tag, Jonathan. Could you please consider to add it into your patch? I didn't see it in -mm1 tree or I can give you a patch.

CC Jonathan Corbet <[email protected]>

Thanks!

[1] http://lkml.org/lkml/2007/10/11/255

Signature · 1 line
May the Source Be With You.
#4 lore raw

PATCH 1/1 drivers/net/wireless/b43legacy/main.c: initialize the correct return value

In reply to Adrian Bunk

Initialize "err" in drivers/net/wireless/b43legacy/main.c::b43legacy_start() in case of returning an uninitialized value.

From: Adrian Bunk <[email protected]>

---
 drivers/net/wireless/b43/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/b43legacy/main.c +1 -1
Index: linux-2.6.23-mm1/drivers/net/wireless/b43legacy/main.c
===================================================================
@@ -3306,7 +3306,7 @@ static int b43legacy_start(struct ieee80
 	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
 	struct b43legacy_wldev *dev = wl->current_dev;
 	int did_init = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&wl->mutex);
 
#5 lore raw

Re: [-mm Patch] drivers/net/wireless/b43legacy/main.c: initialize the correct return value

Quoted 15 lines · WANG Cong

Initialize "err" in drivers/net/wireless/b43legacy/main.c::b43legacy_start() in case of returning an uninitialized value.

From: Adrian Bunk <[email protected]>

---
 drivers/net/wireless/b43/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.23-mm1/drivers/net/wireless/b43legacy/main.c
===================================================================

drivers/net/wireless/b43legacy/main.c static int b43legacy_start(struct ieee80 · line 3311

Quoted 7 lines
drivers/net/wireless/b43legacy/main.c +1 -1
@@ -3306,7 +3306,7 @@ static int b43legacy_start(struct ieee80
 	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
 	struct b43legacy_wldev *dev = wl->current_dev;
 	int did_init = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&wl->mutex);

I sent the equivalent patch to John Linville yesterday.

Larry