All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] BRCM80211: improve readability on addresses copy
@ 2021-05-11  7:02 Íñigo Huguet
  2021-06-01  9:06 ` Íñigo Huguet
  2021-06-15 10:40 ` brcmsmac: " Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Íñigo Huguet @ 2021-05-11  7:02 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, Kalle Valo, David S. Miller,
	Jakub Kicinski, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, netdev, linux-kernel

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.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
index 763e0ec583d7..26de1bd7fee9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
@@ -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
-- 
2.31.1


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

* Re: [PATCH] BRCM80211: improve readability on addresses copy
  2021-05-11  7:02 [PATCH] BRCM80211: improve readability on addresses copy Íñigo Huguet
@ 2021-06-01  9:06 ` Íñigo Huguet
  2021-06-15 10:40 ` brcmsmac: " Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Íñigo Huguet @ 2021-06-01  9:06 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, Kalle Valo, David S. Miller,
	Jakub Kicinski, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, netdev, linux-kernel

On Tue, May 11, 2021 at 9:04 AM Íñigo Huguet <ihuguet@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
> index 763e0ec583d7..26de1bd7fee9 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
> @@ -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
> --
> 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!
-- 
Íñigo Huguet


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

* Re: brcmsmac: improve readability on addresses copy
  2021-05-11  7:02 [PATCH] BRCM80211: improve readability on addresses copy Íñigo Huguet
  2021-06-01  9:06 ` Íñigo Huguet
@ 2021-06-15 10:40 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2021-06-15 10:40 UTC (permalink / raw)
  To: Íñigo Huguet
  Cc: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, David S. Miller, Jakub Kicinski,
	linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	netdev, linux-kernel

Íñigo Huguet <ihuguet@redhat.com> wrote:

> 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.
> 
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

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

c0277e25d28f brcmsmac: improve readability on addresses copy

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210511070257.7843-1-ihuguet@redhat.com/

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


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

end of thread, other threads:[~2021-06-15 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  7:02 [PATCH] BRCM80211: improve readability on addresses copy Íñigo Huguet
2021-06-01  9:06 ` Íñigo Huguet
2021-06-15 10:40 ` brcmsmac: " Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.