Skip to contentSkip to conversation

brcmfmac: Fix off by one bug in brcmf_count_20mhz_channels()

PATCH In review Emil Goode 2 participants 2 messages Sep 22, 2014 – Sep 23, 2014

Subsystems (4)
lore
Share & tools
lore

Emil Goode

author
#0 lore raw

PATCH v2 1/1 brcmfmac: Fix off by one bug in brcmf_count_20mhz_channels()

In the brcmf_count_20mhz_channels function we are looping through a list of channels received from firmware. Since the index of the first channel is 0 the condition leads to an off by one bug. This is causing us to hit the WARN_ON_ONCE(1) calls in the brcmu_d11n_decchspec function, which is how I discovered the bug.

Introduced by:
commit b48d891676f756d48b4d0ee131e4a7a5d43ca417
("brcmfmac: rework wiphy structure setup")

---
v2: Added Arends "Acked-by" tag.

 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +1 -1
index 12a60ca..0517687 100644
@@ -4924,7 +4924,7 @@ static void brcmf_count_20mhz_channels(struct brcmf_cfg80211_info *cfg,
 	struct brcmu_chan ch;
 	int i;
 
-	for (i = 0; i <= total; i++) {
+	for (i = 0; i < total; i++) {
 		ch.chspec = (u16)le32_to_cpu(chlist->element[i]);
 		cfg->d11inf.decchspec(&ch);
 
Signature · 1 line
2.1.0
#1 lore raw
Quoted 10 lines · Emil Goode

In the brcmf_count_20mhz_channels function we are looping through a list of channels received from firmware. Since the index of the first channel is 0 the condition leads to an off by one bug. This is causing us to hit the WARN_ON_ONCE(1) calls in the brcmu_d11n_decchspec function, which is how I discovered the bug.

Introduced by:
commit b48d891676f756d48b4d0ee131e4a7a5d43ca417
("brcmfmac: rework wiphy structure setup")

Hi John,

This bug was introduced in 3.17 so can it still go in the wireless tree? I verified it applies to wireless/master branch.

Regards,
Arend

Quoted 21 lines

---
v2: Added Arends "Acked-by" tag.

  drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +1 -1
index 12a60ca..0517687 100644
@@ -4924,7 +4924,7 @@ static void brcmf_count_20mhz_channels(struct brcmf_cfg80211_info *cfg,
  	struct brcmu_chan ch;
  	int i;
 
-	for (i = 0; i<= total; i++) {
+	for (i = 0; i<  total; i++) {
  		ch.chspec = (u16)le32_to_cpu(chlist->element[i]);
  		cfg->d11inf.decchspec(&ch);