public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: bhanuseshukumar <bhanuseshukumar@gmail.com>
To: Sahil Chandna <chandna.linuxkernel@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 17:07:34 +0530	[thread overview]
Message-ID: <68484d2e-653a-4256-bd99-47f1a9b740f8@gmail.com> (raw)
In-Reply-To: <b0cdffc2-7db2-4aee-aca7-ddb068d5022a@gmail.com>

On 30/09/25 16:54, Sahil Chandna wrote:
> 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); ?

I didn't change the order of arguments to make it easier to review. 
> 
>>       if (!buff)
>>           return -ENOMEM;
> 


  reply	other threads:[~2025-09-30 11:39 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
2025-09-30 11:37   ` bhanuseshukumar [this message]
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=68484d2e-653a-4256-bd99-47f1a9b740f8@gmail.com \
    --to=bhanuseshukumar@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chandna.linuxkernel@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