]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/mlx5: convert miss_list allocation to kvmalloc_array()
authorWilliam Theesfeld <william@theesfeld.net>
Mon, 1 Jun 2026 19:37:58 +0000 (15:37 -0400)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jun 2026 16:33:24 +0000 (09:33 -0700)
dr_icm_buddy_init_ste_cache() allocates the per-buddy miss_list using
the open-coded kvmalloc(n * sizeof(*p), ...) form.  The neighbouring
allocations in the same function already use the kvcalloc()/
kvzalloc_objs() forms; switch this last one to kvmalloc_array() for
consistency and for the size_mul overflow check that kvmalloc_array()
performs.

The semantics are unchanged: kvmalloc_array() returns a non-zeroed
buffer, just like the previous kvmalloc() call.  Existing callers of
buddy->miss_list initialise each list_head before use.

Signed-off-by: William Theesfeld <william@theesfeld.net>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260601193758.626537-1-william@theesfeld.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c

index 7a0a1582239250995455dbf84ca876045f513be5..fa4d24b3dfaabc84948c21396ad96f57a8302bcd 100644 (file)
@@ -239,7 +239,7 @@ static int dr_icm_buddy_init_ste_cache(struct mlx5dr_icm_buddy_mem *buddy)
        if (!buddy->hw_ste_arr)
                goto free_ste_arr;
 
-       buddy->miss_list = kvmalloc(num_of_entries * sizeof(struct list_head), GFP_KERNEL);
+       buddy->miss_list = kvmalloc_array(num_of_entries, sizeof(struct list_head), GFP_KERNEL);
        if (!buddy->miss_list)
                goto free_hw_ste_arr;