Re: [PATCH net-next 3/6] net/mlx5: HWS, Replace kzalloc with kzalloc_obj
From: netdev-bot+sashiko
Date: Wed Sep 16 2026 - 19:47:21 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] Commit message names the wrong helper and does not describe the
actual (partial) scope of the change.
--
net/mlx5: HWS, Replace kzalloc with kzalloc_obj
This converts one allocation in hws_send_ring_alloc_sq() from an open-coded
kzalloc(sizeof(*p) * n, GFP_KERNEL) to the newer object-array allocation
macro.
> net/mlx5: HWS, Replace kzalloc with kzalloc_obj
>
> Replace kzalloc with the newer kzalloc_obj allocation function.
[Severity: Low]
This isn't a bug in the code, but does the changelog name the right helper?
The subject and body both say kzalloc_obj, while the only converted site
uses the array variant kzalloc_objs(). include/linux/slab.h defines these
as two separate macros:
#define kzalloc_obj(P, ...) \
__alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), 1)
#define kzalloc_objs(P, COUNT, ...) \
__alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)
Grepping this patch for kzalloc_obj as written in the message finds nothing.
Also, the message reads as a general replacement sweep, but only this one
array allocation is converted. The single-object kzalloc(sizeof(*x),
GFP_KERNEL) sites that kzalloc_obj would actually apply to are still present
in the same driver, for example in hws/bwc_complex.c:
subm->bwc_matcher = kzalloc(sizeof(*subm->bwc_matcher), GFP_KERNEL);
as well as the cdata and sr_data allocations in the same file, and they
remain unconverted at the end of the series. Could the message mention that
the conversion is limited to this call site?
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> index 80cfd0ddba08b..49dee44d0bef5 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> @@ -732,7 +732,7 @@ static int hws_send_ring_alloc_sq(struct mlx5_core_dev *mdev,
> goto destroy_wq_cyc;
> }
>
> - sq->wr_priv = kzalloc(sizeof(*sq->wr_priv) * buf_sz, GFP_KERNEL);
> + sq->wr_priv = kzalloc_objs(*sq->wr_priv, buf_sz);
> if (!sq->wr_priv) {
> err = -ENOMEM;
> goto free_dep_wqe;
The expansion here looks equivalent to the old code, with default_gfp()
yielding GFP_KERNEL and __alloc_objs() using size_mul() for the product, so
no functional change is expected.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260915111912.3926585-1-tariqt%40nvidia.com