Skip to content

Commit f634460

Browse files
Lucas De Marchitorvalds
authored andcommitted
kmod: split call to call_usermodehelper_fns()
Use call_usermodehelper_setup() + call_usermodehelper_exec() instead of calling call_usermodehelper_fns(). In case the latter returns -ENOMEM the cleanup function may had not been called - in this case we would not free argv and module_name. Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi> Cc: Oleg Nesterov <oleg@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: James Morris <james.l.morris@oracle.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Tejun Heo <tj@kernel.org> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 938e4b2 commit f634460

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎kernel/kmod.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
7777

7878
static int call_modprobe(char *module_name, int wait)
7979
{
80+
struct subprocess_info *info;
8081
static char *envp[] = {
8182
"HOME=/",
8283
"TERM=linux",
@@ -98,8 +99,15 @@ static int call_modprobe(char *module_name, int wait)
9899
argv[3] = module_name; /* check free_modprobe_argv() */
99100
argv[4] = NULL;
100101

101-
return call_usermodehelper_fns(modprobe_path, argv, envp,
102-
wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
102+
info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
103+
NULL, free_modprobe_argv, NULL);
104+
if (!info)
105+
goto free_module_name;
106+
107+
return call_usermodehelper_exec(info, wait | UMH_KILLABLE);
108+
109+
free_module_name:
110+
kfree(module_name);
103111
free_argv:
104112
kfree(argv);
105113
out:

0 commit comments

Comments
 (0)