mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] CRED: Fix memory leak in error handling
@ 2010-03-29 23:04 David Howells
  0 siblings, 0 replies; only message in thread
From: David Howells @ 2010-03-29 23:04 UTC (permalink / raw)
  To: linux-security-module; +Cc: linux-kernel, Mathieu Desnoyers, David Howells

From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Fix a memory leak on an OOM condition in prepare_usermodehelper_creds().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 kernel/cred.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/cred.c b/kernel/cred.c
index 1ed8ca1..1b1129d 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -364,7 +364,7 @@ struct cred *prepare_usermodehelper_creds(void)
 
 	new = kmem_cache_alloc(cred_jar, GFP_ATOMIC);
 	if (!new)
-		return NULL;
+		goto free_tgcred;
 
 	kdebug("prepare_usermodehelper_creds() alloc %p", new);
 
@@ -397,6 +397,10 @@ struct cred *prepare_usermodehelper_creds(void)
 
 error:
 	put_cred(new);
+free_tgcred:
+#ifdef CONFIG_KEYS
+	kfree(tgcred);
+#endif
 	return NULL;
 }
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-29 23:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-29 23:04 [PATCH] CRED: Fix memory leak in error handling David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®