From: Lance Richardson <lrichard@redhat.com>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: netdev@vger.kernel.org,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Johannes Berg <johannes@sipsolutions.net>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH net 1/5] macsec: add missing NULL check after kmalloc
Date: Tue, 19 Apr 2016 13:45:47 -0400 (EDT) [thread overview]
Message-ID: <1625750535.15145234.1461087947312.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <c986bb2421c817eeb00416bd2055f69040924af5.1460967681.git.sd@queasysnail.net>
----- Original Message -----
> From: "Sabrina Dubroca" <sd@queasysnail.net>
> To: netdev@vger.kernel.org
> Cc: "Hannes Frederic Sowa" <hannes@stressinduktion.org>, "Johannes Berg" <johannes@sipsolutions.net>, "Dan Carpenter"
> <dan.carpenter@oracle.com>, "Sabrina Dubroca" <sd@queasysnail.net>
> Sent: Tuesday, April 19, 2016 1:36:38 PM
> Subject: [PATCH net 1/5] macsec: add missing NULL check after kmalloc
>
> 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)) {
Doesn't this leak rx_sa if kmalloc() succeeds but init_rx_sa fails?
> rtnl_unlock();
> return -ENOMEM;
> }
> --
> 2.8.0
>
>
next prev parent reply other threads:[~2016-04-19 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 17:36 [PATCH net 0/5] macsec: a few fixes Sabrina Dubroca
2016-04-19 17:36 ` [PATCH net 1/5] macsec: add missing NULL check after kmalloc Sabrina Dubroca
2016-04-19 17:45 ` Lance Richardson [this message]
2016-04-19 20:25 ` Sabrina Dubroca
2016-04-19 17:36 ` [PATCH net 2/5] macsec: take rtnl lock before for_each_netdev Sabrina Dubroca
2016-04-19 17:36 ` [PATCH net 3/5] macsec: don't put a NULL rxsa Sabrina Dubroca
2016-04-19 17:36 ` [PATCH net 4/5] macsec: fix rx_sa refcounting with decrypt callback Sabrina Dubroca
2016-04-19 17:36 ` [PATCH net 5/5] macsec: add consistency check to netlink dumps Sabrina Dubroca
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=1625750535.15145234.1461087947312.JavaMail.zimbra@redhat.com \
--to=lrichard@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=hannes@stressinduktion.org \
--cc=johannes@sipsolutions.net \
--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).