public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: kernel-janitors@vger.kernel.org
Subject: Re: macsec: introduce IEEE 802.1AE driver
Date: Wed, 16 Mar 2016 10:22:44 +0000	[thread overview]
Message-ID: <20160316102244.GA20043@bistromath> (raw)
In-Reply-To: <20160315211241.GA17317@mwanda>

Hello Dan,

2016-03-16, 00:12:41 +0300, Dan Carpenter wrote:
> Hello Sabrina Dubroca,
> 
> The patch c09440f7dcb3: "macsec: introduce IEEE 802.1AE driver" from
> Mar 11, 2016, leads to the following Smatch warnings:
> 
>     drivers/net/macsec.c:714 macsec_encrypt()
>     warn: 'skb->dev' held on error path.
> 
> drivers/net/macsec.c
>    711          dev_hold(skb->dev);
>                 ^^^^^^^^^^^^^^^^^^
>    712          ret = crypto_aead_encrypt(req);
>    713          if (ret = -EINPROGRESS) {
>    714                  return ERR_PTR(ret);
> 
> Need to dev_put() before returning.

In this case, no.  We want to hold a reference on the netdevice, and
it is released by the crypto callback (macsec_encrypt_done(), or
macsec_decrypt_done() in the second case).

[snip second case]


>     drivers/net/macsec.c:1624 macsec_add_rxsa()
>     error: potential null dereference 'rx_sa'.  (kmalloc returns null)

Right, I'm missing a NULL check here.  I'll send a fix.


>   1616          }
>   1617  
>   1618          rx_sa = rtnl_dereference(rx_sc->sa[assoc_num]);
>   1619          if (rx_sa) {
>   1620                  rtnl_unlock();
>   1621                  return -EBUSY;
>   1622          }
>   1623  
>   1624          rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   1625          if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
>                                ^^^^^
> Dereferenced inside function.
> 
>   1626                         secy->icv_len)) {
>   1627                  rtnl_unlock();
>   1628                  return -ENOMEM;
>   1629          }
>   1630  


Thanks for the report!

-- 
Sabrina

      reply	other threads:[~2016-03-16 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 21:12 macsec: introduce IEEE 802.1AE driver Dan Carpenter
2016-03-16 10:22 ` Sabrina Dubroca [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=20160316102244.GA20043@bistromath \
    --to=sd@queasysnail.net \
    --cc=kernel-janitors@vger.kernel.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