Skip to contentSkip to conversation

BRCM80211: improve readability on addresses copy

PATCH In review Íñigo Huguet 2 participants 3 messages May 11, 2021 – Jun 15, 2021

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

PATCH 1/1 BRCM80211: improve readability on addresses copy

A static analyzer identified as a potential bug the copy of 12 bytes from a 6 bytes array to a 6 bytes array. Both arrays are 6 bytes addresses.

Although not being a real bug, it is not immediately clear why is done this way: next 6 bytes address, contiguous to the first one, must also be copied to next contiguous 6 bytes address of the destination.

Copying each one separately will make both static analyzers and reviewers happier.

---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +2 -1
index 763e0ec583d7..26de1bd7fee9 100644
@@ -6607,7 +6607,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
 			rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
 							 IEEE80211_STYPE_RTS);
 
-			memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN);
+			memcpy(&rts->ra, &h->addr1, ETH_ALEN);
+			memcpy(&rts->ta, &h->addr2, ETH_ALEN);
 		}
 
 		/* mainrate
Signature · 1 line
2.31.1
#1 lore raw
Quoted 33 lines · Íñigo Huguet

A static analyzer identified as a potential bug the copy of 12 bytes from a 6 bytes array to a 6 bytes array. Both arrays are 6 bytes addresses.

Although not being a real bug, it is not immediately clear why is done this way: next 6 bytes address, contiguous to the first one, must also be copied to next contiguous 6 bytes address of the destination.

Copying each one separately will make both static analyzers and reviewers happier.

---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +2 -2
index 763e0ec583d7..26de1bd7fee9 100644
@@ -6607,7 +6607,8 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
                        rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
                                                         IEEE80211_STYPE_RTS);
 
-                       memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN);
+                       memcpy(&rts->ra, &h->addr1, ETH_ALEN);
+                       memcpy(&rts->ta, &h->addr2, ETH_ALEN);
                }
 
                /* mainrate
--
Quoted 2 lines

2.31.1

Hello,

About 3 weeks ago I sent this patch, just with a small style change proposal. Any feedback would be appreciated.

Thanks!

Signature · 1 line
Íñigo Huguet
#2 lore raw

Re: brcmsmac: improve readability on addresses copy

In reply to Íñigo Huguet
Quoted 9 lines · Íñigo Huguet

A static analyzer identified as a potential bug the copy of 12 bytes from a 6 bytes array to a 6 bytes array. Both arrays are 6 bytes addresses.

Although not being a real bug, it is not immediately clear why is done this way: next 6 bytes address, contiguous to the first one, must also be copied to next contiguous 6 bytes address of the destination.

Quoted 4 lines

Copying each one separately will make both static analyzers and reviewers happier.

Patch applied to wireless-drivers-next.git, thanks.

c0277e25d28f brcmsmac: improve readability on addresses copy

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

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