public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: gustavo@embeddedor.com (Gustavo A. R. Silva)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] net: thunderx: nicvf_main: Fix potential NULL pointer dereference
Date: Tue, 3 Apr 2018 16:52:37 -0500	[thread overview]
Message-ID: <15d8d776-3768-b93e-8e38-0f2387668477@embeddedor.com> (raw)
In-Reply-To: <f0deebb5-06e8-d788-0e68-0c15c979028c@gmail.com>



On 04/03/2018 04:47 PM, Eric Dumazet wrote:
> 
> 
> On 04/03/2018 02:29 PM, Gustavo A. R. Silva wrote:
>> Add null check on kmalloc() return value in order to prevent
>> a null pointer dereference.
>>
>> Addresses-Coverity-ID: 1467429 ("Dereference null return value")
>> Fixes: 37c3347eb247 ("net: thunderx: add ndo_set_rx_mode callback implementation for VF")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>>   drivers/net/ethernet/cavium/thunder/nicvf_main.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
>> index 1e9a31f..468321a 100644
>> --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
>> +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
>> @@ -1999,6 +1999,8 @@ static void nicvf_set_rx_mode(struct net_device *netdev)
>>   				struct xcast_addr *xaddr;
>>   
>>   				mc_list = kmalloc(sizeof(*mc_list), GFP_ATOMIC);
>> +				if (unlikely(!mc_list))
>> +					return;
>>   				INIT_LIST_HEAD(&mc_list->list);
>>   				netdev_hw_addr_list_for_each(ha, &netdev->mc) {
>>   					xaddr = kmalloc(sizeof(*xaddr),
>>
> 
> What about the second kmalloc() right there ?
> 

Oops. I thought I had it covered.

I'll send v2 with that change shortly.

Thanks for the feedback, Eric.
--
Gustavo

      reply	other threads:[~2018-04-03 21:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 21:29 [PATCH] net: thunderx: nicvf_main: Fix potential NULL pointer dereference Gustavo A. R. Silva
2018-04-03 21:47 ` Eric Dumazet
2018-04-03 21:52   ` Gustavo A. R. Silva [this message]

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=15d8d776-3768-b93e-8e38-0f2387668477@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=linux-arm-kernel@lists.infradead.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