Re: [PATCH net-next] ntp: fix size argument for kcalloc

From: Przemek Kitszel
Date: Wed Jul 03 2024 - 05:16:57 EST


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@xxxxxxxxxxx>
---
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@xxxxxxxxx>