Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f634460c authored by Lucas De Marchi's avatar Lucas De Marchi Committed by Linus Torvalds
Browse files

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: default avatarLucas 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 938e4b22
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ static void free_modprobe_argv(struct subprocess_info *info)


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


	return call_usermodehelper_fns(modprobe_path, argv, envp,
	info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
		wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
					 NULL, free_modprobe_argv, NULL);
	if (!info)
		goto free_module_name;

	return call_usermodehelper_exec(info, wait | UMH_KILLABLE);

free_module_name:
	kfree(module_name);
free_argv:
free_argv:
	kfree(argv);
	kfree(argv);
out:
out: