Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfp: xsk: Adjust allocation type for nn->dp.xsk_pools

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>

authored by

Kees Cook and committed by
Jakub Kicinski
c636eed6 01cbf838

+1 -1
+1 -1
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
··· 2538 2538 nn->dp.num_r_vecs, num_online_cpus()); 2539 2539 nn->max_r_vecs = nn->dp.num_r_vecs; 2540 2540 2541 - nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(nn->dp.xsk_pools), 2541 + nn->dp.xsk_pools = kcalloc(nn->max_r_vecs, sizeof(*nn->dp.xsk_pools), 2542 2542 GFP_KERNEL); 2543 2543 if (!nn->dp.xsk_pools) { 2544 2544 err = -ENOMEM;