diff mbox series

[wpan-next,v2,6/9] net: ieee802154: Use the IEEE802154_MAX_PAGE define when relevant

Message ID 20220120112115.448077-7-miquel.raynal@bootlin.com (mailing list archive)
State Superseded
Headers show
Series ieee802154: A bunch of fixes | expand

Commit Message

Miquel Raynal Jan. 20, 2022, 11:21 a.m. UTC
This define already exist but is hardcoded in nl-phy.c. Use the
definition when relevant.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 net/ieee802154/nl-phy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Stefan Schmidt Jan. 21, 2022, 4 p.m. UTC | #1
Hello.

On 20.01.22 12:21, Miquel Raynal wrote:
> This define already exist but is hardcoded in nl-phy.c. Use the
> definition when relevant.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>   net/ieee802154/nl-phy.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
> index dd5a45f8a78a..02f6a53d0faa 100644
> --- a/net/ieee802154/nl-phy.c
> +++ b/net/ieee802154/nl-phy.c
> @@ -30,7 +30,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>   {
>   	void *hdr;
>   	int i, pages = 0;
> -	uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
> +	uint32_t *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(uint32_t),

Please use u32 here. I know we have some uint*_t leftovers but for new 
code we should not use them anymore.

> +				GFP_KERNEL);
>   
>   	pr_debug("%s\n", __func__);
>   
> @@ -47,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>   	    nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
>   	    nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
>   		goto nla_put_failure;
> -	for (i = 0; i < 32; i++) {
> +	for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
>   		if (phy->supported.channels[i])
>   			buf[pages++] = phy->supported.channels[i] | (i << 27);
>   	}
> 

regards
Stefan Schmidt
Alexander Aring Jan. 23, 2022, 8:44 p.m. UTC | #2
Hi,

On Thu, 20 Jan 2022 at 06:21, Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> This define already exist but is hardcoded in nl-phy.c. Use the
> definition when relevant.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  net/ieee802154/nl-phy.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
> index dd5a45f8a78a..02f6a53d0faa 100644
> --- a/net/ieee802154/nl-phy.c
> +++ b/net/ieee802154/nl-phy.c
> @@ -30,7 +30,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>  {
>         void *hdr;
>         int i, pages = 0;
> -       uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
> +       uint32_t *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(uint32_t),
> +                               GFP_KERNEL);
>
>         pr_debug("%s\n", __func__);
>
> @@ -47,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>             nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
>             nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
>                 goto nla_put_failure;
> -       for (i = 0; i < 32; i++) {
> +       for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
>                 if (phy->supported.channels[i])
>                         buf[pages++] = phy->supported.channels[i] | (i << 27);
>         }

Where is the fix here?

- Alex
Stefan Schmidt Jan. 24, 2022, 8:06 a.m. UTC | #3
Hello.

On 23.01.22 21:44, Alexander Aring wrote:
> Hi,
> 
> On Thu, 20 Jan 2022 at 06:21, Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>>
>> This define already exist but is hardcoded in nl-phy.c. Use the
>> definition when relevant.
>>
>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> ---
>>   net/ieee802154/nl-phy.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
>> index dd5a45f8a78a..02f6a53d0faa 100644
>> --- a/net/ieee802154/nl-phy.c
>> +++ b/net/ieee802154/nl-phy.c
>> @@ -30,7 +30,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>>   {
>>          void *hdr;
>>          int i, pages = 0;
>> -       uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
>> +       uint32_t *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(uint32_t),
>> +                               GFP_KERNEL);
>>
>>          pr_debug("%s\n", __func__);
>>
>> @@ -47,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
>>              nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
>>              nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
>>                  goto nla_put_failure;
>> -       for (i = 0; i < 32; i++) {
>> +       for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
>>                  if (phy->supported.channels[i])
>>                          buf[pages++] = phy->supported.channels[i] | (i << 27);
>>          }
> 
> Where is the fix here?

While its more cleanup than fix, its clear and easy and there is no 
problem for it to go into wpan instead of wpan-next.

regards
Stefan Schmidt
Miquel Raynal Jan. 25, 2022, 11:10 a.m. UTC | #4
Hi Stefan,

stefan@datenfreihafen.org wrote on Mon, 24 Jan 2022 09:06:39 +0100:

> Hello.
> 
> On 23.01.22 21:44, Alexander Aring wrote:
> > Hi,
> > 
> > On Thu, 20 Jan 2022 at 06:21, Miquel Raynal <miquel.raynal@bootlin.com> wrote:  
> >>
> >> This define already exist but is hardcoded in nl-phy.c. Use the
> >> definition when relevant.
> >>
> >> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> >> ---
> >>   net/ieee802154/nl-phy.c | 5 +++--
> >>   1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
> >> index dd5a45f8a78a..02f6a53d0faa 100644
> >> --- a/net/ieee802154/nl-phy.c
> >> +++ b/net/ieee802154/nl-phy.c
> >> @@ -30,7 +30,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
> >>   {
> >>          void *hdr;
> >>          int i, pages = 0;
> >> -       uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
> >> +       uint32_t *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(uint32_t),
> >> +                               GFP_KERNEL);
> >>
> >>          pr_debug("%s\n", __func__);
> >>
> >> @@ -47,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
> >>              nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
> >>              nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
> >>                  goto nla_put_failure;
> >> -       for (i = 0; i < 32; i++) {
> >> +       for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
> >>                  if (phy->supported.channels[i])
> >>                          buf[pages++] = phy->supported.channels[i] | (i << 27);
> >>          }  
> > 
> > Where is the fix here?  
> 
> While its more cleanup than fix, its clear and easy and there is no problem for it to go into wpan instead of wpan-next.

As answered earlier, I will split the series so that it's clearer what
should go to wpan and what should go to wpan-next, no problem with that.

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index dd5a45f8a78a..02f6a53d0faa 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -30,7 +30,8 @@  static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
 {
 	void *hdr;
 	int i, pages = 0;
-	uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
+	uint32_t *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(uint32_t),
+				GFP_KERNEL);
 
 	pr_debug("%s\n", __func__);
 
@@ -47,7 +48,7 @@  static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
 	    nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
 	    nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
 		goto nla_put_failure;
-	for (i = 0; i < 32; i++) {
+	for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
 		if (phy->supported.channels[i])
 			buf[pages++] = phy->supported.channels[i] | (i << 27);
 	}