lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 26 Jan 2015 06:45:23 +0100
From:	Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:	herbert@...dor.apana.org.au, davem@...emloft.net
CC:	linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] crypto: omap: Free memory in error path

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@...adoo.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;
>   	}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ