Netdev List
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Kees Cook <kees@kernel.org>
Cc: Sunil Goutham <sgoutham@marvell.com>,
	Kees Cook <kees+treewide@kernel.org>,
	Geetha sowjanya <gakula@marvell.com>,
	"Subbaraya Sundeep" <sbhatta@marvell.com>,
	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>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>
Subject: Re: [PATCH net-next] octeontx2-af: Allocate ikpu2 with ARRAY_SIZE()
Date: Fri, 18 Sep 2026 07:32:34 +0530	[thread overview]
Message-ID: <aqybujD1TdU2wziP@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260917211409.i.425-kees@kernel.org>

On 2026-09-18 at 02:44:10, Kees Cook (kees@kernel.org) wrote:
> From: Kees Cook <kees+treewide@kernel.org>
>
> In preparation for making the devm_kmalloc family of allocators type
> aware, we need to make sure that the returned type from the allocation
> matches the type of the variable being assigned. (Before, the allocator
> would always return "void *", which can be implicitly cast to any
> pointer type.)
>
> This is allocating room for a copy of ikpu_action_entries, which is an
> array of struct npc_kpu_profile_action, but it asked for a single object
> the size of the whole array, which would make the allocation type a
> pointer to the array rather than the "struct npc_kpu_profile_action *"
> being assigned. Allocate ARRAY_SIZE-many entries instead. The resulting
> allocation size is the same.
>
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> @@ -1959,8 +1959,9 @@ static int npc_apply_custom_kpu_from_fs(struct rvu *rvu,
>  	fw = rvu->kpu_fwdata;
>
>  	/* Binary blob contains ikpu actions entries at start of data[0] */
> -	profile->ikpu2 = devm_kcalloc(rvu->dev, 1,
> -				      sizeof(ikpu_action_entries),
> +	profile->ikpu2 = devm_kcalloc(rvu->dev,
> +				      ARRAY_SIZE(ikpu_action_entries),
> +				      sizeof(*profile->ikpu2),
>  				      GFP_KERNEL);
Reviewed-by: Ratheesh Kannoth <rkannoth@marvell.com>

  reply	other threads:[~2026-09-18  2:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 21:14 [PATCH net-next] octeontx2-af: Allocate ikpu2 with ARRAY_SIZE() Kees Cook
2026-09-18  2:02 ` Ratheesh Kannoth [this message]
2026-09-22  0:50 ` patchwork-bot+netdevbpf

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=aqybujD1TdU2wziP@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=kees+treewide@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.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