From: Sahil Chandna <chandna.linuxkernel@gmail.com>
To: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>,
epomozov@marvell.com, irusskikh@marvell.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH] net: atlantic: Use kmalloc_array to prevent overflow of dynamic size calculation
Date: Tue, 30 Sep 2025 16:54:33 +0530 [thread overview]
Message-ID: <b0cdffc2-7db2-4aee-aca7-ddb068d5022a@gmail.com> (raw)
In-Reply-To: <20250930111933.28730-1-bhanuseshukumar@gmail.com>
On 30/09/2025 16:49, Bhanu Seshu Kumar Valluri wrote:
> Use kmalloc_array to avoid potential overflow during dynamic size calculation
> inside kmalloc.
>
> Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
> ---
> Note: Patch is tested for compilation.
> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> index 5acb3e16b567..f445d449f80f 100644
> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> @@ -182,7 +182,7 @@ static unsigned int aq_ptp_skb_buf_len(struct ptp_skb_ring *ring)
>
> static int aq_ptp_skb_ring_init(struct ptp_skb_ring *ring, unsigned int size)
> {
> - struct sk_buff **buff = kmalloc(sizeof(*buff) * size, GFP_KERNEL);
> + struct sk_buff **buff = kmalloc_array(sizeof(*buff), size, GFP_KERNEL);
>
Shouldn't this be kmalloc_array(size, sizeof(*buff), GFP_KERNEL); ?
> if (!buff)
> return -ENOMEM;
next prev parent reply other threads:[~2025-09-30 11:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 11:19 [PATCH] net: atlantic: Use kmalloc_array to prevent overflow of dynamic size calculation Bhanu Seshu Kumar Valluri
2025-09-30 11:24 ` Sahil Chandna [this message]
2025-09-30 11:37 ` bhanuseshukumar
2025-09-30 12:17 ` Eric Dumazet
2025-09-30 13:12 ` Bhanu Seshu Kumar Valluri
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=b0cdffc2-7db2-4aee-aca7-ddb068d5022a@gmail.com \
--to=chandna.linuxkernel@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bhanuseshukumar@gmail.com \
--cc=davem@davemloft.net \
--cc=david.hunter.linux@gmail.com \
--cc=edumazet@google.com \
--cc=epomozov@marvell.com \
--cc=irusskikh@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=skhan@linuxfoundation.org \
/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