]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
CRED: Fix memory leak in error handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 29 Mar 2010 23:04:00 +0000 (00:04 +0100)
committerJames Morris <jmorris@namei.org>
Tue, 30 Mar 2010 06:15:38 +0000 (17:15 +1100)
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>
Signed-off-by: James Morris <jmorris@namei.org>
kernel/cred.c

index 1ed8ca18790c1e937208af47bed6695f4218858b..1b1129d0cce87077055704c78d4ae364d8fb4cc8 100644 (file)
@@ -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;
 }