linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Johannes Berg <johannes.berg@intel.com>,
	Taehee Yoo <ap420073@gmail.com>, Andreas Steinmetz <ast@domdv.de>,
	Michal Kubecek <mkubecek@suse.cz>,
	Florian Westphal <fw@strlen.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	emamd001@umn.edu
Subject: Re: [PATCH] macsec: Fix memory leaks in macsec_decrypt()
Date: Fri, 22 Nov 2019 23:26:36 +0100	[thread overview]
Message-ID: <20191122222636.GA21689@breakpoint.cc> (raw)
In-Reply-To: <20191122220242.29359-1-navid.emamdoost@gmail.com>

Navid Emamdoost <navid.emamdoost@gmail.com> wrote:
> In the implementation of macsec_decrypt(), there are two memory leaks
> when crypto_aead_decrypt() fails. Release allocated req and skb before
> return.
> 
> Fixes: c3b7d0bd7ac2 ("macsec: fix rx_sa refcounting with decrypt callback")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/net/macsec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index afd8b2a08245..34c6fb4eb9ef 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -986,6 +986,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
>  	dev_hold(dev);
>  	ret = crypto_aead_decrypt(req);
>  	if (ret == -EINPROGRESS) {
> +		aead_request_free(req);
> +		kfree_skb(skb);

-EINPROGRESS means decryption is handled asynchronously, no?

>  		return ERR_PTR(ret);
>  	} else if (ret != 0) {
>  		/* decryption/authentication failed

This is the error handling/failure path.

      reply	other threads:[~2019-11-22 22:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 22:02 [PATCH] macsec: Fix memory leaks in macsec_decrypt() Navid Emamdoost
2019-11-22 22:26 ` Florian Westphal [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=20191122222636.GA21689@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=ap420073@gmail.com \
    --cc=ast@domdv.de \
    --cc=davem@davemloft.net \
    --cc=emamd001@umn.edu \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=navid.emamdoost@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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).