Commit 570b8fb5 authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by James Morris

CRED: Fix memory leak in error handling

Fix a memory leak on an OOM condition in prepare_usermodehelper_creds().
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 9623e5a2
...@@ -364,7 +364,7 @@ struct cred *prepare_usermodehelper_creds(void) ...@@ -364,7 +364,7 @@ struct cred *prepare_usermodehelper_creds(void)
new = kmem_cache_alloc(cred_jar, GFP_ATOMIC); new = kmem_cache_alloc(cred_jar, GFP_ATOMIC);
if (!new) if (!new)
return NULL; goto free_tgcred;
kdebug("prepare_usermodehelper_creds() alloc %p", new); kdebug("prepare_usermodehelper_creds() alloc %p", new);
...@@ -397,6 +397,10 @@ struct cred *prepare_usermodehelper_creds(void) ...@@ -397,6 +397,10 @@ struct cred *prepare_usermodehelper_creds(void)
error: error:
put_cred(new); put_cred(new);
free_tgcred:
#ifdef CONFIG_KEYS
kfree(tgcred);
#endif
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment