LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] crypto: omap: Free memory in error path
@ 2015-01-26  5:40 Christophe Jaillet
  2015-01-26  5:45 ` Christophe JAILLET
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Jaillet @ 2015-01-26  5:40 UTC (permalink / raw)
  To: herbert, davem
  Cc: linux-crypto, linux-kernel, kernel-janitors, Christophe Jaillet

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;
 	}
-- 
2.1.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-26  5:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26  5:40 [PATCH] crypto: omap: Free memory in error path Christophe Jaillet
2015-01-26  5:45 ` Christophe JAILLET

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