LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] crypto: omap: Free memory in error path
Date: Mon, 26 Jan 2015 06:45:23 +0100	[thread overview]
Message-ID: <54C5D473.4060204@wanadoo.fr> (raw)
In-Reply-To: <1422250858-22516-1-git-send-email-christophe.jaillet@wanadoo.fr>

Oups,

should be:
      free_pages((unsigned long)buf_out, pages);
      free_pages((unsigned long)buf_in, pages);


CJ

Le 26/01/2015 06:40, Christophe Jaillet a écrit :
> If only one of the 2 __get_free_pages fails, then there is a memory leak
>
> Signed-off-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/crypto/omap-aes.c | 2 ++
>   drivers/crypto/omap-des.c | 2 ++
>   2 files changed, 4 insertions(+)
>
> diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
> index f79dd41..c2f9333 100644
> --- a/drivers/crypto/omap-aes.c
> +++ b/drivers/crypto/omap-aes.c
> @@ -577,6 +577,8 @@ static int omap_aes_copy_sgs(struct omap_aes_dev *dd)
>   	buf_out = (void *)__get_free_pages(GFP_ATOMIC, pages);
>   
>   	if (!buf_in || !buf_out) {
> +		free_page((unsigned long)buf_out);
> +		free_page((unsigned long)buf_in);
>   		pr_err("Couldn't allocated pages for unaligned cases.\n");
>   		return -1;
>   	}
> diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
> index 0b8dcf5..a2f6ca1 100644
> --- a/drivers/crypto/omap-des.c
> +++ b/drivers/crypto/omap-des.c
> @@ -570,6 +570,8 @@ static int omap_des_copy_sgs(struct omap_des_dev *dd)
>   	buf_out = (void *)__get_free_pages(GFP_ATOMIC, pages);
>   
>   	if (!buf_in || !buf_out) {
> +		free_page((unsigned long)buf_out);
> +		free_page((unsigned long)buf_in);
>   		pr_err("Couldn't allocated pages for unaligned cases.\n");
>   		return -1;
>   	}


      reply	other threads:[~2015-01-26  5:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26  5:40 Christophe Jaillet
2015-01-26  5:45 ` Christophe JAILLET [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=54C5D473.4060204@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] crypto: omap: Free memory in error path' \
    /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

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).