Skip to content

Commit

Permalink
kmod: convert two call sites to call_usermodehelper_fns()
Browse files Browse the repository at this point in the history
Both kernel/sys.c && security/keys/request_key.c where inlining the exact
same code as call_usermodehelper_fns(); So simply convert these sites to
directly use call_usermodehelper_fns().

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Boaz Harrosh authored and Linus Torvalds committed Jun 1, 2012
1 parent ae3cef7 commit 81ab6e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
19 changes: 8 additions & 11 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -2114,26 +2114,23 @@ int orderly_poweroff(bool force)
NULL
};
int ret = -ENOMEM;
struct subprocess_info *info;

if (argv == NULL) {
printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n",
__func__, poweroff_cmd);
goto out;
}

info = call_usermodehelper_setup(argv[0], argv, envp, GFP_ATOMIC);
if (info == NULL) {
argv_free(argv);
goto out;
}

call_usermodehelper_setfns(info, NULL, argv_cleanup, NULL);
ret = call_usermodehelper_fns(argv[0], argv, envp, UMH_NO_WAIT,
NULL, argv_cleanup, NULL);
out:
if (likely(!ret))
return 0;

ret = call_usermodehelper_exec(info, UMH_NO_WAIT);
if (ret == -ENOMEM)
argv_free(argv);

out:
if (ret && force) {
if (force) {
printk(KERN_WARNING "Failed to start orderly shutdown: "
"forcing the issue\n");

Expand Down
13 changes: 3 additions & 10 deletions security/keys/request_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,9 @@ 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)
{
gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
struct subprocess_info *info =
call_usermodehelper_setup(path, argv, envp, gfp_mask);

if (!info)
return -ENOMEM;

call_usermodehelper_setfns(info, umh_keys_init, umh_keys_cleanup,
key_get(session_keyring));
return call_usermodehelper_exec(info, wait);
return call_usermodehelper_fns(path, argv, envp, wait,
umh_keys_init, umh_keys_cleanup,
key_get(session_keyring));
}

/*
Expand Down

0 comments on commit 81ab6e7

Please sign in to comment.