From: Lucas De Marchi Date: Wed, 20 Mar 2013 04:08:28 +0000 (+1100) Subject: KEYS: split call to call_usermodehelper_fns() X-Git-Tag: next-20130322~1^2~105 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a29db2b018db805088a70e314fb39c3e2b4779ae;p=karo-tx-linux.git KEYS: split call to call_usermodehelper_fns() Use call_usermodehelper_setup() + call_usermodehelper_exec() instead of calling call_usermodehelper_fns(). In case there's an OOM in this last function the cleanup function may not be called - in this case we would miss a call to key_put(). Signed-off-by: Lucas De Marchi Cc: Oleg Nesterov Cc: David Howells Acked-by: James Morris Cc: Al Viro Cc: Tejun Heo Cc: "Rafael J. Wysocki" Signed-off-by: Andrew Morton --- diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 4bd6bdb74193..c411f9bb156b 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -93,9 +93,16 @@ static void umh_keys_cleanup(struct subprocess_info *info) static int call_usermodehelper_keys(char *path, char **argv, char **envp, struct key *session_keyring, int wait) { - return call_usermodehelper_fns(path, argv, envp, wait, - umh_keys_init, umh_keys_cleanup, - key_get(session_keyring)); + struct subprocess_info *info; + + info = call_usermodehelper_setup(path, argv, envp, GFP_KERNEL, + umh_keys_init, umh_keys_cleanup, + session_keyring); + if (!info) + return -ENOMEM; + + key_get(session_keyring); + return call_usermodehelper_exec(info, wait); } /*