netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ntp: fix size argument for kcalloc
@ 2024-07-03  2:56 Chen Ni
  2024-07-03  9:16 ` Przemek Kitszel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Chen Ni @ 2024-07-03  2:56 UTC (permalink / raw)
  To: louis.peens, kuba, davem, edumazet, pabeni, horms, yinjun.zhang,
	johannes.berg, ryno.swart, ziyang.chen, linma, niklas.soderlund
  Cc: oss-drivers, netdev, linux-kernel, Chen Ni

The size argument to kcalloc should be the size of desired structure,
not the pointer to it.

Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 182ba0a8b095..768f22cd3d02 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2539,7 +2539,7 @@ nfp_net_alloc(struct pci_dev *pdev, const struct nfp_dev_info *dev_info,
 				  nn->dp.num_r_vecs, num_online_cpus());
 	nn->max_r_vecs = nn->dp.num_r_vecs;
 
-	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(nn->dp.xsk_pools),
+	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(*nn->dp.xsk_pools),
 				   GFP_KERNEL);
 	if (!nn->dp.xsk_pools) {
 		err = -ENOMEM;
-- 
2.25.1


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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-03  2:56 [PATCH net-next] ntp: fix size argument for kcalloc Chen Ni
@ 2024-07-03  9:16 ` Przemek Kitszel
  2024-07-04  9:36   ` Paolo Abeni
  2024-07-04  5:36 ` Louis Peens
  2024-07-04  7:30 ` Simon Horman
  2 siblings, 1 reply; 8+ messages in thread
From: Przemek Kitszel @ 2024-07-03  9:16 UTC (permalink / raw)
  To: Chen Ni
  Cc: oss-drivers, netdev, linux-kernel, louis.peens, kuba, davem,
	edumazet, pabeni, horms, yinjun.zhang, johannes.berg, ryno.swart,
	ziyang.chen, linma, niklas.soderlund

On 7/3/24 04:56, Chen Ni wrote:
> The size argument to kcalloc should be the size of desired structure,

xsk_pools is a double pointer, so not "desired structure" but rather you
should talk about an element size.

> not the pointer to it.
> 
> Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")

even if the the behavior is not changed, the fix should be targeted to
net tree

> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>   drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> index 182ba0a8b095..768f22cd3d02 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> @@ -2539,7 +2539,7 @@ nfp_net_alloc(struct pci_dev *pdev, const struct nfp_dev_info *dev_info,
>   				  nn->dp.num_r_vecs, num_online_cpus());
>   	nn->max_r_vecs = nn->dp.num_r_vecs;
>   
> -	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(nn->dp.xsk_pools),
> +	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(*nn->dp.xsk_pools),
>   				   GFP_KERNEL);
>   	if (!nn->dp.xsk_pools) {
>   		err = -ENOMEM;

code change is correct, even if the size is the same
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-03  2:56 [PATCH net-next] ntp: fix size argument for kcalloc Chen Ni
  2024-07-03  9:16 ` Przemek Kitszel
@ 2024-07-04  5:36 ` Louis Peens
  2024-07-04  7:30 ` Simon Horman
  2 siblings, 0 replies; 8+ messages in thread
From: Louis Peens @ 2024-07-04  5:36 UTC (permalink / raw)
  To: Chen Ni
  Cc: kuba, davem, edumazet, pabeni, horms, yinjun.zhang, johannes.berg,
	ryno.swart, ziyang.chen, linma, niklas.soderlund, oss-drivers,
	netdev, linux-kernel

Wed, Jul 03, 2024 at 10:56:25AM +0800, Chen Ni wrote:
> The size argument to kcalloc should be the size of desired structure,
> not the pointer to it.
> 
> Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> index 182ba0a8b095..768f22cd3d02 100644
> --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
> @@ -2539,7 +2539,7 @@ nfp_net_alloc(struct pci_dev *pdev, const struct nfp_dev_info *dev_info,
>  				  nn->dp.num_r_vecs, num_online_cpus());
>  	nn->max_r_vecs = nn->dp.num_r_vecs;
>  
> -	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(nn->dp.xsk_pools),
> +	nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(*nn->dp.xsk_pools),
>  				   GFP_KERNEL);
>  	if (!nn->dp.xsk_pools) {
>  		err = -ENOMEM;
> -- 
Looks good to me, thanks.

Signed-off-by: Louis Peens <louis.peens@corigine.com>

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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-03  2:56 [PATCH net-next] ntp: fix size argument for kcalloc Chen Ni
  2024-07-03  9:16 ` Przemek Kitszel
  2024-07-04  5:36 ` Louis Peens
@ 2024-07-04  7:30 ` Simon Horman
  2 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-07-04  7:30 UTC (permalink / raw)
  To: Chen Ni
  Cc: louis.peens, kuba, davem, edumazet, pabeni, yinjun.zhang,
	johannes.berg, ryno.swart, ziyang.chen, linma, niklas.soderlund,
	oss-drivers, netdev, linux-kernel

On Wed, Jul 03, 2024 at 10:56:25AM +0800, Chen Ni wrote:
> The size argument to kcalloc should be the size of desired structure,
> not the pointer to it.
> 
> Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>

nit: s/ntp/nfp/ in the subject

...

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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-03  9:16 ` Przemek Kitszel
@ 2024-07-04  9:36   ` Paolo Abeni
  2024-07-04  9:41     ` Paolo Abeni
  0 siblings, 1 reply; 8+ messages in thread
From: Paolo Abeni @ 2024-07-04  9:36 UTC (permalink / raw)
  To: Przemek Kitszel, Chen Ni
  Cc: oss-drivers, netdev, linux-kernel, louis.peens, kuba, davem,
	edumazet, horms, yinjun.zhang, johannes.berg, ryno.swart,
	ziyang.chen, linma, niklas.soderlund

On Wed, 2024-07-03 at 11:16 +0200, Przemek Kitszel wrote:
> On 7/3/24 04:56, Chen Ni wrote:
> > The size argument to kcalloc should be the size of desired structure,
> 
> xsk_pools is a double pointer, so not "desired structure" but rather you
> should talk about an element size.
> 
> > not the pointer to it.
> > 
> > Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
> 
> even if the the behavior is not changed, the fix should be targeted to
> net tree

This patch is IMHO more a cleanup than a real fix. As such it's more
suited for net-next. For the same reason I think it should not go to
stable, so I'm dropping the fixes tag, too.

Thanks,

Paolo


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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-04  9:36   ` Paolo Abeni
@ 2024-07-04  9:41     ` Paolo Abeni
  2024-07-04 10:17       ` Przemek Kitszel
  0 siblings, 1 reply; 8+ messages in thread
From: Paolo Abeni @ 2024-07-04  9:41 UTC (permalink / raw)
  To: Przemek Kitszel, Chen Ni
  Cc: oss-drivers, netdev, linux-kernel, louis.peens, kuba, davem,
	edumazet, horms, yinjun.zhang, johannes.berg, ryno.swart,
	ziyang.chen, linma, niklas.soderlund

On Thu, 2024-07-04 at 11:36 +0200, Paolo Abeni wrote:
> On Wed, 2024-07-03 at 11:16 +0200, Przemek Kitszel wrote:
> > On 7/3/24 04:56, Chen Ni wrote:
> > > The size argument to kcalloc should be the size of desired structure,
> > 
> > xsk_pools is a double pointer, so not "desired structure" but rather you
> > should talk about an element size.
> > 
> > > not the pointer to it.
> > > 
> > > Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
> > 
> > even if the the behavior is not changed, the fix should be targeted to
> > net tree
> 
> This patch is IMHO more a cleanup than a real fix. As such it's more
> suited for net-next. For the same reason I think it should not go to
> stable, so I'm dropping the fixes tag, too.

Thinking again about it, this patch has a few things to be cleaned-up. 

@Chen Ni, please submit a new revision, adjusting the subj and commit
message as per Przemek and Simon feedback and dropping the fixes tag,
still targeting net-next. 

You can retain the already collected tags.

Thanks,

Paolo


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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-04  9:41     ` Paolo Abeni
@ 2024-07-04 10:17       ` Przemek Kitszel
  2024-07-04 14:21         ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Przemek Kitszel @ 2024-07-04 10:17 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: oss-drivers, netdev, linux-kernel, louis.peens, kuba, davem,
	edumazet, horms, yinjun.zhang, johannes.berg, ryno.swart,
	ziyang.chen, linma, niklas.soderlund, Chen Ni,
	Sebastian Andrzej Siewior

On 7/4/24 11:41, Paolo Abeni wrote:
> On Thu, 2024-07-04 at 11:36 +0200, Paolo Abeni wrote:
>> On Wed, 2024-07-03 at 11:16 +0200, Przemek Kitszel wrote:
>>> On 7/3/24 04:56, Chen Ni wrote:
>>>> The size argument to kcalloc should be the size of desired structure,
>>>
>>> xsk_pools is a double pointer, so not "desired structure" but rather you
>>> should talk about an element size.
>>>
>>>> not the pointer to it.
>>>>
>>>> Fixes: 6402528b7a0b ("nfp: xsk: add AF_XDP zero-copy Rx and Tx support")
>>>
>>> even if the the behavior is not changed, the fix should be targeted to
>>> net tree
>>
>> This patch is IMHO more a cleanup than a real fix. As such it's more
>> suited for net-next. For the same reason I think it should not go to
>> stable, so I'm dropping the fixes tag, too.

I'm fine with targeting it at any of the trees.

But I still believe it is a fix, even if a trivial one, and even if code
"works" - it's a "wrong" code.

Here I received similar feedback in a similar case:
https://www.mail-archive.com/intel-wired-lan@osuosl.org/msg03252.html
and I changed my mind then.

> 
> Thinking again about it, this patch has a few things to be cleaned-up.
> 
> @Chen Ni, please submit a new revision, adjusting the subj and commit
> message as per Przemek and Simon feedback and dropping the fixes tag,
> still targeting net-next.
> 
> You can retain the already collected tags.
> 
> Thanks,
> 
> Paolo
> 


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

* Re: [PATCH net-next] ntp: fix size argument for kcalloc
  2024-07-04 10:17       ` Przemek Kitszel
@ 2024-07-04 14:21         ` Jakub Kicinski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2024-07-04 14:21 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: Paolo Abeni, oss-drivers, netdev, linux-kernel, louis.peens,
	davem, edumazet, horms, yinjun.zhang, johannes.berg, ryno.swart,
	ziyang.chen, linma, niklas.soderlund, Chen Ni,
	Sebastian Andrzej Siewior

On Thu, 4 Jul 2024 12:17:39 +0200 Przemek Kitszel wrote:
> >> This patch is IMHO more a cleanup than a real fix. As such it's more
> >> suited for net-next. For the same reason I think it should not go to
> >> stable, so I'm dropping the fixes tag, too.  
> 
> I'm fine with targeting it at any of the trees.
> 
> But I still believe it is a fix, even if a trivial one, and even if code
> "works" - it's a "wrong" code.
> 
> Here I received similar feedback in a similar case:
> https://www.mail-archive.com/intel-wired-lan@osuosl.org/msg03252.html
> and I changed my mind then.

Comments, docs, and the MAINTAINERS file are special.
This is actually changing the code, and at present results in the same
binary getting generated.

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

end of thread, other threads:[~2024-07-04 14:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03  2:56 [PATCH net-next] ntp: fix size argument for kcalloc Chen Ni
2024-07-03  9:16 ` Przemek Kitszel
2024-07-04  9:36   ` Paolo Abeni
2024-07-04  9:41     ` Paolo Abeni
2024-07-04 10:17       ` Przemek Kitszel
2024-07-04 14:21         ` Jakub Kicinski
2024-07-04  5:36 ` Louis Peens
2024-07-04  7:30 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).