* [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array()
@ 2026-06-01 19:37 William Theesfeld
2026-06-04 13:31 ` Paolo Abeni
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: William Theesfeld @ 2026-06-01 19:37 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Leon Romanovsky, Tariq Toukan, Mark Bloch, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-rdma, linux-kernel
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>
---
.../net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
index 7a0a15822..fa4d24b3d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
@@ -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;
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array()
2026-06-01 19:37 [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array() William Theesfeld
@ 2026-06-04 13:31 ` Paolo Abeni
2026-06-04 13:49 ` Tariq Toukan
2026-06-04 17:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2026-06-04 13:31 UTC (permalink / raw)
To: William Theesfeld, Saeed Mahameed
Cc: Leon Romanovsky, Tariq Toukan, Mark Bloch, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, netdev, linux-rdma,
linux-kernel
On 6/1/26 9:37 PM, William Theesfeld wrote:
> 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>
> ---
> .../net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> index 7a0a15822..fa4d24b3d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> @@ -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;
@Leon, @Tariq: the patch looks obviously correct to me, still an
explicit ack would be nice, I think.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array()
2026-06-01 19:37 [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array() William Theesfeld
2026-06-04 13:31 ` Paolo Abeni
@ 2026-06-04 13:49 ` Tariq Toukan
2026-06-04 17:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2026-06-04 13:49 UTC (permalink / raw)
To: William Theesfeld, Saeed Mahameed
Cc: Leon Romanovsky, Tariq Toukan, Mark Bloch, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-rdma, linux-kernel
On 01/06/2026 22:37, William Theesfeld wrote:
> 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>
> ---
> .../net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> index 7a0a15822..fa4d24b3d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
> @@ -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;
>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Thanks for your patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array()
2026-06-01 19:37 [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array() William Theesfeld
2026-06-04 13:31 ` Paolo Abeni
2026-06-04 13:49 ` Tariq Toukan
@ 2026-06-04 17:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-04 17:40 UTC (permalink / raw)
To: William Theesfeld
Cc: saeedm, leon, tariqt, mbloch, andrew+netdev, davem, edumazet,
kuba, pabeni, netdev, linux-rdma, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 1 Jun 2026 15:37:58 -0400 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- net/mlx5: convert miss_list allocation to kvmalloc_array()
https://git.kernel.org/netdev/net-next/c/93790c374b9d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-04 17:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01 19:37 [PATCH] net/mlx5: convert miss_list allocation to kvmalloc_array() William Theesfeld
2026-06-04 13:31 ` Paolo Abeni
2026-06-04 13:49 ` Tariq Toukan
2026-06-04 17:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox