Skip to contentSkip to conversation

wcn36xx: Initialize channel to NULL inside wcn36xx_change_opchannel()

PATCH In review Souptick Joarder 3 participants 3 messages Feb 19, 2022 – Feb 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wcn36xx: Initialize channel to NULL inside wcn36xx_change_opchannel()

From: "Souptick Joarder (HPE)" <[email protected]>

Kernel test robot reported below warning -> drivers/net/wireless/ath/wcn36xx/main.c:409:7: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]

Also code walk indicates, if channel is not found in first band, it will break the loop and instead of exit it will go ahead and assign a garbage value in wcn->channel which looks like a bug.

Initialize channel with NULL should avoid this issue.

Fixes d6f2746691cb ("wcn36xx: Track the band and channel we are tuned to")
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +1 -1
index 75661d449712..1a06eff07107 100644
@@ -394,7 +394,7 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
 	struct ieee80211_vif *vif = NULL;
 	struct wcn36xx_vif *tmp;
 	struct ieee80211_supported_band *band;
-	struct ieee80211_channel *channel;
+	struct ieee80211_channel *channel = NULL;
 	unsigned long flags;
 	int i, j;
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Souptick Joarder

From: "Souptick Joarder (HPE)" <[email protected]>

Kernel test robot reported below warning -> drivers/net/wireless/ath/wcn36xx/main.c:409:7: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]

Also code walk indicates, if channel is not found in first band, it will break the loop and instead of exit it will go ahead and assign a garbage value in wcn->channel which looks like a bug.

Quoted 5 lines

Initialize channel with NULL should avoid this issue.

Fixes d6f2746691cb ("wcn36xx: Track the band and channel we are tuned to")
Quoted 20 lines
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +1 -2
index 75661d449712..1a06eff07107 100644
@@ -394,7 +394,7 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
        struct ieee80211_vif *vif = NULL;
        struct wcn36xx_vif *tmp;
        struct ieee80211_supported_band *band;
-       struct ieee80211_channel *channel;
+       struct ieee80211_channel *channel = NULL;
        unsigned long flags;
        int i, j;
 
--

2.25.1

#2 lore raw
In reply to Souptick Joarder
Quoted 25 lines · Souptick Joarder

From: "Souptick Joarder (HPE)" <[email protected]>

Kernel test robot reported below warning -> drivers/net/wireless/ath/wcn36xx/main.c:409:7: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]

Also code walk indicates, if channel is not found in first band, it will break the loop and instead of exit it will go ahead and assign a garbage value in wcn->channel which looks like a bug.

Initialize channel with NULL should avoid this issue.

Fixes d6f2746691cb ("wcn36xx: Track the band and channel we are tuned to")
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/wcn36xx/main.c +0 -0
index 75661d449712..1a06eff07107 100644

drivers/net/wireless/ath/wcn36xx/main.c static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch) · line 399

Quoted 7 lines
drivers/net/wireless/ath/wcn36xx/main.c +1 -1
@@ -394,7 +394,7 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
 	struct ieee80211_vif *vif = NULL;
 	struct wcn36xx_vif *tmp;
 	struct ieee80211_supported_band *band;
-	struct ieee80211_channel *channel;
+	struct ieee80211_channel *channel = NULL;
 	unsigned long flags;
 	int i, j;

I have already applied an identical patch from Dan:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=ath-next&id=11e41e2929378df945bf50b95409d93059ad4507

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches