Skip to contentSkip to conversation

net: mac80211/cfg.c: fix error using of sizeof()

PATCH In review Cong Ding 4 participants 7 messages Feb 6, 2013

Subsystems (3)
lore
Share & tools
lore

Cong Ding

author
#0 lore raw

PATCH 1/1 net: mac80211/cfg.c: fix error using of sizeof()

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

---
 net/mac80211/cfg.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +2 -1
index 661b878..af561d5 100644
@@ -2058,7 +2058,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-	memcpy(sdata->vif.bss_conf.mcast_rate, rate, sizeof(rate));
+	memcpy(sdata->vif.bss_conf.mcast_rate, rate,
+			sizeof(int) * IEEE80211_NUM_BANDS);
 
 	return 0;
 }
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 2 lines · Cong Ding

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

Oops, yeah, Stephen Hemminger pointed this out a month or so ago and I forgot to change it, thanks.

johannes

#2 lore raw
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Cong Ding

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

Oops, yeah, Stephen Hemminger pointed this out a month or so ago and I forgot to change it, thanks.

This needs to be back-ported for 3.7 stable? Perhaps the code below corresponds (from copy_mesh_setup)?

	/* mcast rate setting in Mesh Node */
	memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
						sizeof(setup->mcast_rate));

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#3 lore raw
Quoted 8 lines · Ben Greear
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Cong Ding

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

Oops, yeah, Stephen Hemminger pointed this out a month or so ago and I forgot to change it, thanks.

Quoted 7 lines

This needs to be back-ported for 3.7 stable? Perhaps the code below corresponds (from copy_mesh_setup)?

     /* mcast rate setting in Mesh Node */
     memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
                         sizeof(setup->mcast_rate));

Nevermind..I think I'm wrong about that..the sizeof probably works fine here. Sorry for the noise.

Ben

Quoted 4 lines

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#4 lore raw
In reply to Cong Ding
Quoted 13 lines · Cong Ding

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

---
  net/mac80211/cfg.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +0 -0
index 661b878..af561d5 100644

net/mac80211/cfg.c static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, · line 2062

Quoted 6 lines
net/mac80211/cfg.c +2 -1
@@ -2058,7 +2058,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
  {
  	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-	memcpy(sdata->vif.bss_conf.mcast_rate, rate, sizeof(rate));
+	memcpy(sdata->vif.bss_conf.mcast_rate, rate,
+			sizeof(int) * IEEE80211_NUM_BANDS);

Should it perhaps be: sizeof(*rate) * IEEE80211_NUM_BANDS just in case the type ever changes?

Thanks,
Ben

Quoted 4 lines
net/mac80211/cfg.c +0 -0
  	return 0;
  }
 
Signature · 7 lines
Ben Greear <greearb-my8/[email protected]>
Candela Technologies Inc  http://www.candelatech.com

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#5 lore raw
In reply to Cong Ding

From: Cong Ding <[email protected]>
Date: Wed, 6 Feb 2013 17:23:45 +0100

Quoted 13 lines

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

---
 net/mac80211/cfg.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +0 -0
index 661b878..af561d5 100644

net/mac80211/cfg.c static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, · line 2063

Quoted 7 lines
net/mac80211/cfg.c +2 -1
@@ -2058,7 +2058,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-	memcpy(sdata->vif.bss_conf.mcast_rate, rate, sizeof(rate));
+	memcpy(sdata->vif.bss_conf.mcast_rate, rate,
+			sizeof(int) * IEEE80211_NUM_BANDS);
 

This is not indented properly. The "sizeof(int..." should start at the first column after the openning parenthesis of the memcpy() call.

maintainer
#6 lore raw
Quoted 19 lines · David Miller

From: Cong Ding <[email protected]>
Date: Wed, 6 Feb 2013 17:23:45 +0100

Quoted 16 lines

Using 'sizeof' on array given as function argument returns size of a pointer rather than the size of array.

---
 net/mac80211/cfg.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +0 -0
index 661b878..af561d5 100644
@@ -2058,7 +2058,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
 {
      struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
Quoted 7 lines

net/mac80211/cfg.c static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, · line 2063

Quoted 4 lines
net/mac80211/cfg.c +2 -1
-     memcpy(sdata->vif.bss_conf.mcast_rate, rate, sizeof(rate));
+     memcpy(sdata->vif.bss_conf.mcast_rate, rate,
+                     sizeof(int) * IEEE80211_NUM_BANDS);
 

This is not indented properly. The "sizeof(int..." should start at the first column after the openning parenthesis of the memcpy() call.

Yeah I fixed it when I applied it ... oh well.

johannes