From: Mathieu Desnoyers Date: Mon, 29 Mar 2010 23:04:00 +0000 (+0100) Subject: CRED: Fix memory leak in error handling X-Git-Tag: Ubuntu-5.2.0-15.16~25508^2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=570b8fb505896e007fd3bb07573ba6640e51851d;p=mirror_ubuntu-eoan-kernel.git CRED: Fix memory leak in error handling Fix a memory leak on an OOM condition in prepare_usermodehelper_creds(). Signed-off-by: Mathieu Desnoyers Signed-off-by: David Howells Signed-off-by: James Morris --- diff --git a/kernel/cred.c b/kernel/cred.c index 1ed8ca18790c..1b1129d0cce8 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; }