All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
@ 2013-02-06 16:23 Cong Ding
  2013-02-06 16:27 ` Johannes Berg
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Cong Ding @ 2013-02-06 16:23 UTC (permalink / raw)
  To: Johannes Berg, John W. Linville, David S. Miller, linux-wireless,
	netdev, linux-kernel
  Cc: Cong Ding

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

Signed-off-by: Cong Ding <dinggnu@gmail.com>
---
 net/mac80211/cfg.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 661b878..af561d5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -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;
 }
-- 
1.7.9.5


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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
  2013-02-06 16:23 [PATCH] net: mac80211/cfg.c: fix error using of sizeof() Cong Ding
@ 2013-02-06 16:27 ` Johannes Berg
  2013-02-06 17:54   ` Ben Greear
  2013-02-06 17:58   ` Ben Greear
  2013-02-06 18:33 ` David Miller
  2 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2013-02-06 16:27 UTC (permalink / raw)
  To: Cong Ding
  Cc: John W. Linville, David S. Miller, linux-wireless, netdev, linux-kernel

On Wed, 2013-02-06 at 17:23 +0100, Cong Ding wrote:
> 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


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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
  2013-02-06 16:27 ` Johannes Berg
@ 2013-02-06 17:54   ` Ben Greear
  2013-02-06 17:59     ` Ben Greear
  0 siblings, 1 reply; 8+ messages in thread
From: Ben Greear @ 2013-02-06 17:54 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Cong Ding, John W. Linville, David S. Miller, linux-wireless,
	netdev, linux-kernel

On 02/06/2013 08:27 AM, Johannes Berg wrote:
> On Wed, 2013-02-06 at 17:23 +0100, Cong Ding wrote:
>> 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

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
@ 2013-02-06 17:58   ` Ben Greear
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Greear @ 2013-02-06 17:58 UTC (permalink / raw)
  To: Cong Ding
  Cc: Johannes Berg, John W. Linville, David S. Miller, linux-wireless,
	netdev, linux-kernel

On 02/06/2013 08:23 AM, Cong Ding wrote:
> Using 'sizeof' on array given as function argument returns size of a pointer
> rather than the size of array.
>
> Signed-off-by: Cong Ding <dinggnu@gmail.com>
> ---
>   net/mac80211/cfg.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 661b878..af561d5 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -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

>
>   	return 0;
>   }
>


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
@ 2013-02-06 17:58   ` Ben Greear
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Greear @ 2013-02-06 17:58 UTC (permalink / raw)
  To: Cong Ding
  Cc: Johannes Berg, John W. Linville, David S. Miller,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 02/06/2013 08:23 AM, Cong Ding wrote:
> Using 'sizeof' on array given as function argument returns size of a pointer
> rather than the size of array.
>
> Signed-off-by: Cong Ding <dinggnu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>   net/mac80211/cfg.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 661b878..af561d5 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -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

>
>   	return 0;
>   }
>


-- 
Ben Greear <greearb-my8/4N5VtI7c+919tysfdA@public.gmane.org>
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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
  2013-02-06 17:54   ` Ben Greear
@ 2013-02-06 17:59     ` Ben Greear
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Greear @ 2013-02-06 17:59 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Cong Ding, John W. Linville, David S. Miller, linux-wireless,
	netdev, linux-kernel

On 02/06/2013 09:54 AM, Ben Greear wrote:
> On 02/06/2013 08:27 AM, Johannes Berg wrote:
>> On Wed, 2013-02-06 at 17:23 +0100, Cong Ding wrote:
>>> 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));

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

Ben

>
> Thanks,
> Ben
>


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
  2013-02-06 16:23 [PATCH] net: mac80211/cfg.c: fix error using of sizeof() Cong Ding
  2013-02-06 16:27 ` Johannes Berg
  2013-02-06 17:58   ` Ben Greear
@ 2013-02-06 18:33 ` David Miller
  2013-02-06 19:28   ` Johannes Berg
  2 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2013-02-06 18:33 UTC (permalink / raw)
  To: dinggnu; +Cc: johannes, linville, linux-wireless, netdev, linux-kernel

From: Cong Ding <dinggnu@gmail.com>
Date: Wed,  6 Feb 2013 17:23:45 +0100

> Using 'sizeof' on array given as function argument returns size of a pointer
> rather than the size of array.
> 
> Signed-off-by: Cong Ding <dinggnu@gmail.com>
> ---
>  net/mac80211/cfg.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 661b878..af561d5 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -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.

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

* Re: [PATCH] net: mac80211/cfg.c: fix error using of sizeof()
  2013-02-06 18:33 ` David Miller
@ 2013-02-06 19:28   ` Johannes Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2013-02-06 19:28 UTC (permalink / raw)
  To: David Miller; +Cc: dinggnu, linville, linux-wireless, netdev, linux-kernel

On Wed, 2013-02-06 at 13:33 -0500, David Miller wrote:
> From: Cong Ding <dinggnu@gmail.com>
> Date: Wed,  6 Feb 2013 17:23:45 +0100
> 
> > Using 'sizeof' on array given as function argument returns size of a pointer
> > rather than the size of array.
> > 
> > Signed-off-by: Cong Ding <dinggnu@gmail.com>
> > ---
> >  net/mac80211/cfg.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> > index 661b878..af561d5 100644
> > --- a/net/mac80211/cfg.c
> > +++ b/net/mac80211/cfg.c
> > @@ -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.

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

johannes



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

end of thread, other threads:[~2013-02-06 19:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06 16:23 [PATCH] net: mac80211/cfg.c: fix error using of sizeof() Cong Ding
2013-02-06 16:27 ` Johannes Berg
2013-02-06 17:54   ` Ben Greear
2013-02-06 17:59     ` Ben Greear
2013-02-06 17:58 ` Ben Greear
2013-02-06 17:58   ` Ben Greear
2013-02-06 18:33 ` David Miller
2013-02-06 19:28   ` Johannes Berg

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.