netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lino Sanfilippo <lsanfil@marvell.com>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: <netdev@vger.kernel.org>, Lance Richardson <lrichard@redhat.com>,
	Hannes Frederic Sowa <hannes@stressinduktion.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc
Date: Fri, 22 Apr 2016 12:06:11 +0200	[thread overview]
Message-ID: <5719F793.4020202@marvell.com> (raw)
In-Reply-To: <20160422094826.GA17059@bistromath.localdomain>



On 22.04.2016 11:48, Sabrina Dubroca wrote:
> 2016-04-22, 11:35:03 +0200, Lino Sanfilippo wrote:
>>
>>
>> On 22.04.2016 11:28, Sabrina Dubroca wrote:
>>> Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
>>> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>>> ---
>>>    drivers/net/macsec.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
>>> index 84d3e5ca8817..f691030ee3df 100644
>>> --- a/drivers/net/macsec.c
>>> +++ b/drivers/net/macsec.c
>>> @@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
>>>    	}
>>>
>>>    	rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
>>> -	if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
>>> -		       secy->icv_len)) {
>>> +	if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
>>> +				 secy->key_len, secy->icv_len)) {
>>>    		rtnl_unlock();
>>>    		return -ENOMEM;
>>>    	}
>>
>>
>> In case that kmalloc was successful and init_rx_sa failed, the allocated memory should be freed, shouldnt it?.
>
> Yep, Lance pointed that out in v1:
> http://marc.info/?l=linux-netdev&m=146108796406155
>
> But since we have the same code with init_tx_sa, I decided to fix both
> in a separate patch (7/9 in this set).
>

Ah ok, sorry about the noise then :)

Regards,
Lino

  reply	other threads:[~2016-04-22 10:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22  9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
2016-04-22  9:35   ` Lino Sanfilippo
2016-04-22  9:48     ` Sabrina Dubroca
2016-04-22 10:06       ` Lino Sanfilippo [this message]
2016-04-22  9:28 ` [PATCH net v2 2/9] macsec: take rtnl lock before for_each_netdev Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 3/9] macsec: don't put a NULL rxsa Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 4/9] macsec: fix rx_sa refcounting with decrypt callback Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 5/9] macsec: add consistency check to netlink dumps Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 6/9] macsec: fix memory leaks around rx_handler (un)registration Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 7/9] macsec: fix SA leak if initialization fails Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 8/9] macsec: add missing macsec prefix in uapi Sabrina Dubroca
2016-04-22  9:28 ` [PATCH net v2 9/9] macsec: fix netlink attribute validation Sabrina Dubroca
2016-04-24 18:32 ` [PATCH net v2 0/9] macsec: a few fixes David Miller

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=5719F793.4020202@marvell.com \
    --to=lsanfil@marvell.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hannes@stressinduktion.org \
    --cc=johannes@sipsolutions.net \
    --cc=lrichard@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /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;
as well as URLs for NNTP newsgroup(s).