]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfp: xsk: Adjust allocation type for nn->dp.xsk_pools
authorKees Cook <kees@kernel.org>
Sat, 26 Apr 2025 06:08:42 +0000 (23:08 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Apr 2025 18:00:05 +0000 (11:00 -0700)
In preparation for making the kmalloc family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type "struct xsk_buff_pool **", but the returned type will be
"struct xsk_buff_pool ***". These are the same allocation size (pointer
size), but the types don't match. Adjust the allocation type to match
the assignment.

Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250426060841.work.016-kees@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index 95514fabadf2730b8d8229639ebcb3cda8db4aa5..28997ddab9664a8ea9bfdde98e8602e68954a7b9 100644 (file)
@@ -2538,7 +2538,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;