CRED: Fix memory leak in error handling
PATCH 1/1 CRED: Fix memory leak in error handling
From: Mathieu Desnoyers <[email protected]>
Fix a memory leak on an OOM condition in prepare_usermodehelper_creds().
Signed-off-by Mathieu Desnoyers <[email protected]>
Signed-off-by David Howells <[email protected]>
---
kernel/cred.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
kernel/cred.c +5 -1
@@ -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 ; }