From 2a46ca46e145386eb72f97cd4b01c313ab06b780 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Fri, 23 Mar 2012 15:02:50 -0700 Subject: [PATCH] --- yaml --- r: 295273 b: refs/heads/master c: 1cc684ab75123efe7ff446eb821d44375ba8fa30 h: refs/heads/master i: 295271: 38f547a385aa08513843c85bb4815ed64dd54466 v: v3 --- [refs] | 2 +- trunk/kernel/kmod.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 8b46b8b2abd4..6703131bac5e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3e63a93b987685f02421e18b2aa452d20553a88b +refs/heads/master: 1cc684ab75123efe7ff446eb821d44375ba8fa30 diff --git a/trunk/kernel/kmod.c b/trunk/kernel/kmod.c index 56a29e812ff0..957a7aab8ebc 100644 --- a/trunk/kernel/kmod.c +++ b/trunk/kernel/kmod.c @@ -60,6 +60,12 @@ static DECLARE_RWSEM(umhelper_sem); */ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; +static void free_modprobe_argv(struct subprocess_info *info) +{ + kfree(info->argv[3]); /* check call_modprobe() */ + kfree(info->argv); +} + static int call_modprobe(char *module_name, int wait) { static char *envp[] = { @@ -69,10 +75,26 @@ static int call_modprobe(char *module_name, int wait) NULL }; - char *argv[] = { modprobe_path, "-q", "--", module_name, NULL }; + char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL); + if (!argv) + goto out; + + module_name = kstrdup(module_name, GFP_KERNEL); + if (!module_name) + goto free_argv; + + argv[0] = modprobe_path; + argv[1] = "-q"; + argv[2] = "--"; + argv[3] = module_name; /* check free_modprobe_argv() */ + argv[4] = NULL; return call_usermodehelper_fns(modprobe_path, argv, envp, - wait, NULL, NULL, NULL); + wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL); +free_argv: + kfree(argv); +out: + return -ENOMEM; } /**