* [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c
@ 2015-05-01 11:08 Abhishek Bist
2015-05-03 19:54 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Abhishek Bist @ 2015-05-01 11:08 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, abhishek, stankus.modestas, Abhishek Bist
This is a patch which fixes memcpy warning found by a checpatch.pl in p80211conv.c
and replaces memcpy with ether_addr_copy.
Signed-off-by: Abhishek-Bist <ishubist@gmail.com>
---
drivers/staging/wlan-ng/p80211conv.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index bd69e8c..87661ba 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -178,21 +178,23 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
switch (wlandev->macmode) {
case WLAN_MACMODE_IBSS_STA:
- memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr,
+ ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
break;
case WLAN_MACMODE_ESS_STA:
fc |= cpu_to_le16(WLAN_SET_FC_TODS(1));
- memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr,
+ ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
break;
case WLAN_MACMODE_ESS_AP:
fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1));
- memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
break;
default:
netdev_err(wlandev->netdev,
@@ -241,7 +243,7 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
for (i = 0; i < wlandev->spy_number; i++) {
if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
- memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
+ ether_addr_copy(wlandev->spy_address[i], mac, ETH_ALEN);
wlandev->spy_stat[i].level = rxmeta->signal;
wlandev->spy_stat[i].noise = rxmeta->noise;
wlandev->spy_stat[i].qual =
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c
2015-05-01 11:08 [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c Abhishek Bist
@ 2015-05-03 19:54 ` Greg KH
2015-05-05 10:55 ` Abhishek Bist
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2015-05-03 19:54 UTC (permalink / raw)
To: Abhishek Bist; +Cc: linux-kernel, abhishek, stankus.modestas
On Fri, May 01, 2015 at 04:38:37PM +0530, Abhishek Bist wrote:
> This is a patch which fixes memcpy warning found by a checpatch.pl in p80211conv.c
> and replaces memcpy with ether_addr_copy.
How do you "know" it is safe to do this? Please prove it.
>
> Signed-off-by: Abhishek-Bist <ishubist@gmail.com>
Your From: name and this name do not match :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c
2015-05-03 19:54 ` Greg KH
@ 2015-05-05 10:55 ` Abhishek Bist
2015-05-06 5:32 ` Sudip Mukherjee
2015-05-10 13:07 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Abhishek Bist @ 2015-05-05 10:55 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Abhishek Bist
This is a patch which fixes memcpy warning found by a checpatch.pl in p80211conv.c
and replaces memcpy with ether_addr_copy.
---
drivers/staging/wlan-ng/p80211conv.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index bd69e8c..b3f48074 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -178,21 +178,21 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
switch (wlandev->macmode) {
case WLAN_MACMODE_IBSS_STA:
- memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+ ether_addr_copy(p80211_hdr->a3.a3, wlandev->bssid);
break;
case WLAN_MACMODE_ESS_STA:
fc |= cpu_to_le16(WLAN_SET_FC_TODS(1));
- memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, wlandev->bssid);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr);
+ ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.daddr);
break;
case WLAN_MACMODE_ESS_AP:
fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1));
- memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN);
- memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN);
- memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
+ ether_addr_copy(p80211_hdr->a3.a1, &e_hdr.daddr);
+ ether_addr_copy(p80211_hdr->a3.a2, wlandev->bssid);
+ ether_addr_copy(p80211_hdr->a3.a3, &e_hdr.saddr);
break;
default:
netdev_err(wlandev->netdev,
@@ -241,7 +241,7 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
for (i = 0; i < wlandev->spy_number; i++) {
if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
- memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
+ ether_addr_copy(wlandev->spy_address[i], mac);
wlandev->spy_stat[i].level = rxmeta->signal;
wlandev->spy_stat[i].noise = rxmeta->noise;
wlandev->spy_stat[i].qual =
--
1.8.3.1
How do you "know" it is safe to do this? Please prove it.
Yes, it is safe to do this because the basic pre-requisite of ether_addr_copy() over memcpy() is that ether_addr_copy()
is strictly designed to copy an ethernet address where source and destination are a 6 byte array which is true in my case as
p80211_hdr->a3.a1,p80211_hdr->a3.a2,p80211_hdr->a3.a3 are all a six byte array and the next important thing is that they should
be u16 alligned.So, for that sake i checked it by pahole which clearly shows that the source and destination are u16 byte alligned.And on some architecture ether_addr_copy is faster than memcpy().
So, it's seems fair enough to use ether_addr_copy() over memcpy() when the size of data to be copied is ETH_ALEN which is
#define ETH_ALEN 6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c
2015-05-05 10:55 ` Abhishek Bist
@ 2015-05-06 5:32 ` Sudip Mukherjee
2015-05-10 13:07 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-05-06 5:32 UTC (permalink / raw)
To: Abhishek Bist; +Cc: gregkh, linux-kernel
On Tue, May 05, 2015 at 04:25:31PM +0530, Abhishek Bist wrote:
> This is a patch which fixes memcpy warning found by a checpatch.pl in p80211conv.c
> and replaces memcpy with ether_addr_copy.
> ---
you missed the the Signed-off-by:
regards
sudip
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c
2015-05-05 10:55 ` Abhishek Bist
2015-05-06 5:32 ` Sudip Mukherjee
@ 2015-05-10 13:07 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2015-05-10 13:07 UTC (permalink / raw)
To: Abhishek Bist; +Cc: linux-kernel
On Tue, May 05, 2015 at 04:25:31PM +0530, Abhishek Bist wrote:
> This is a patch which fixes memcpy warning found by a checpatch.pl in p80211conv.c
> and replaces memcpy with ether_addr_copy.
> ---
> drivers/staging/wlan-ng/p80211conv.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
We need proof this is ok to do, like I asked last time :(
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-10 21:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-01 11:08 [PATCH] Staging : wlan-ng: fix memcpy with ether_addr_copy in p80211conv.c Abhishek Bist
2015-05-03 19:54 ` Greg KH
2015-05-05 10:55 ` Abhishek Bist
2015-05-06 5:32 ` Sudip Mukherjee
2015-05-10 13:07 ` Greg KH
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.