Skip to content

Commit

Permalink
CRED: Fix memory leak in error handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
compudj authored and James Morris committed Mar 30, 2010
1 parent 9623e5a commit 570b8fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -397,6 +397,10 @@ struct cred *prepare_usermodehelper_creds(void)

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

Expand Down

0 comments on commit 570b8fb

Please sign in to comment.