[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1422250858-22516-1-git-send-email-christophe.jaillet@wanadoo.fr>
Date: Mon, 26 Jan 2015 06:40:58 +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,
Christophe Jaillet <christophe.jaillet@...adoo.fr>
Subject: [PATCH] crypto: omap: Free memory in error path
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;
}
--
2.1.0
--
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