[PATCH] cred fix error handling

From: Mathieu Desnoyers
Date: Mon Mar 29 2010 - 10:05:45 EST


Causes memory leak on OO mem condition.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
CC: David Howells <dhowells@xxxxxxxxxx>
---
kernel/cred.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux.trees.git/kernel/cred.c
===================================================================
--- linux.trees.git.orig/kernel/cred.c 2010-03-29 09:40:53.000000000 -0400
+++ linux.trees.git/kernel/cred.c 2010-03-29 10:03:15.000000000 -0400
@@ -364,7 +364,7 @@ struct cred *prepare_usermodehelper_cred

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_cred

error:
put_cred(new);
+free_tgcred:
+#ifdef CONFIG_KEYS
+ kfree(tgcred);
+#endif
return NULL;
}


--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/