From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Weimin Xiong <xiongwm2026@163.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
<intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [Intel-wired-lan] [PATCH] ice: parser: use array_size() for table allocation
Date: Mon, 20 Jul 2026 17:05:41 +0200 [thread overview]
Message-ID: <28460003-47ee-4706-ad95-7fba87d36509@intel.com> (raw)
In-Reply-To: <20260716025100.118145-1-xiongwm2026@163.com>
From: Weimin Xiong <xiongwm2026@163.com>
Date: Thu, 16 Jul 2026 10:51:00 +0800
> Use array_size() when calculating the parser table allocation size so an
> overflow in the firmware-provided item dimensions is detected before
> allocation. Include the overflow helpers explicitly instead of relying on
> an indirect include.
>
> Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
> ---
> diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
> index f8e69630f..c109d3c32 100644
> --- a/drivers/net/ethernet/intel/ice/ice_parser.c
> +++ b/drivers/net/ethernet/intel/ice/ice_parser.c
> @@ -1,6 +1,8 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright (C) 2024 Intel Corporation */
>
> +#include <linux/overflow.h>
This is redundant.
> +
> #include "ice_common.h"
>
> struct ice_pkg_sect_hdr {
> @@ -102,7 +104,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 = kzalloc(array_size(item_size, length), GFP_KERNEL);
kcalloc(length, item_size) if you want to make it _proper_.
array_size() is used only when no array allocation helpers are
available, e.g. for dma_alloc_coherent(). For regular slab allocations,
we have a whole bunch of different array allocation helpers.
> if (!table)
> return ERR_PTR(-ENOMEM);
Thanks,
Olek
next prev parent reply other threads:[~2026-07-20 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 2:51 [PATCH] ice: parser: use array_size() for table allocation Weimin Xiong
2026-07-20 15:05 ` Alexander Lobakin [this message]
2026-07-21 1:57 ` [PATCH v2] ice: parser: use kcalloc " Weimin Xiong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28460003-47ee-4706-ad95-7fba87d36509@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=xiongwm2026@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox