aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/kmod.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 56a29e812ff0..957a7aab8ebc 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -60,6 +60,12 @@ static DECLARE_RWSEM(umhelper_sem);
60*/ 60*/
61char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; 61char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
62 62
63static void free_modprobe_argv(struct subprocess_info *info)
64{
65 kfree(info->argv[3]); /* check call_modprobe() */
66 kfree(info->argv);
67}
68
63static int call_modprobe(char *module_name, int wait) 69static int call_modprobe(char *module_name, int wait)
64{ 70{
65 static char *envp[] = { 71 static char *envp[] = {
@@ -69,10 +75,26 @@ static int call_modprobe(char *module_name, int wait)
69 NULL 75 NULL
70 }; 76 };
71 77
72 char *argv[] = { modprobe_path, "-q", "--", module_name, NULL }; 78 char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
79 if (!argv)
80 goto out;
81
82 module_name = kstrdup(module_name, GFP_KERNEL);
83 if (!module_name)
84 goto free_argv;
85
86 argv[0] = modprobe_path;
87 argv[1] = "-q";
88 argv[2] = "--";
89 argv[3] = module_name; /* check free_modprobe_argv() */
90 argv[4] = NULL;
73 91
74 return call_usermodehelper_fns(modprobe_path, argv, envp, 92 return call_usermodehelper_fns(modprobe_path, argv, envp,
75 wait, NULL, NULL, NULL); 93 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
94free_argv:
95 kfree(argv);
96out:
97 return -ENOMEM;
76} 98}
77 99
78/** 100/**