RE: [Intel-wired-lan] [PATCH v2] ice: parser: use kcalloc for table allocation
From: Loktionov, Aleksandr
Date: Thu Jul 23 2026 - 05:21:52 EST
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf
> Of Weimin Xiong
> Sent: Tuesday, July 21, 2026 3:58 AM
> To: intel-wired-lan@xxxxxxxxxxxxxxxx
> Cc: Lobakin, Aleksander <aleksander.lobakin@xxxxxxxxx>; Nguyen,
> Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; andrew+netdev@xxxxxxx; davem@xxxxxxxxxxxxx;
> edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx
> Subject: [Intel-wired-lan] [PATCH v2] ice: parser: use kcalloc for
> table allocation
>
> From 376dfdfc788a853c79a87c4bfdd94dc1ea678c43 Mon Sep 17 00:00:00 2001
> From: Weimin Xiong <xiongwm2026@xxxxxxx>
> Date: Tue, 21 Jul 2026 09:46:46 +0800
> Subject: [PATCH v2] ice: parser: use kcalloc for table allocation
> To: intel-wired-lan@xxxxxxxxxxxxxxxx
> Cc: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>,
> Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>,
> Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx>,
> netdev@xxxxxxxxxxxxxxx,
> linux-kernel@xxxxxxxxxxxxxxx,
> Andrew Lunn <andrew+netdev@xxxxxxx>,
> "David S. Miller" <davem@xxxxxxxxxxxxx>,
> "Eric Dumazet" <edumazet@xxxxxxxxxx>,
> Jakub Kicinski <kuba@xxxxxxxxxx>,
> Paolo Abeni <pabeni@xxxxxxxxxx>
> In-Reply-To: <28460003-47ee-4706-ad95-7fba87d36509@xxxxxxxxx>
> References: <20260716025100.118145-1-xiongwm2026@xxxxxxx>
>
> Use kcalloc() when calculating the parser table allocation size so an
> overflow in the firmware-provided item dimensions is detected before
> allocation.
>
> v2: Use kcalloc() instead of kzalloc(array_size()) as suggested by
> Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
>
> ---
>
> v1->v2:
> - Remove redundant include of <linux/overflow.h>
> - Use kcalloc() instead of kzalloc(array_size()) as suggested by
> Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
>
> Signed-off-by: Weimin Xiong <xiongwm2026@xxxxxxx>
> ---
> drivers/net/ethernet/intel/ice/ice_parser.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c
> b/drivers/net/ethernet/intel/ice/ice_parser.c
> index f8e69630f..f5ae6c071 100644
> --- a/drivers/net/ethernet/intel/ice/ice_parser.c
> +++ b/drivers/net/ethernet/intel/ice/ice_parser.c
> @@ -102,7 +102,7 @@ ice_parser_create_table(struct ice_hw *hw, u32
> sect_type,
> if (!seg)
> return ERR_PTR(-EINVAL);
>
> - table = kzalloc(item_size * length, GFP_KERNEL);
> + table = kcalloc(length, item_size, GFP_KERNEL);
> if (!table)
> return ERR_PTR(-ENOMEM);
>
>
> base-commit: 95e24e90b55ce6d9d266ed6f20514f37c931c751
> --
> 2.43.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>