mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.de.marchi@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 2/3] kmod: Use argv_split(), passing module as extra param
Date: Fri, 10 May 2013 01:15:15 -0300	[thread overview]
Message-ID: <1368159316-31744-2-git-send-email-lucas.de.marchi@gmail.com> (raw)
In-Reply-To: <1368159316-31744-1-git-send-email-lucas.de.marchi@gmail.com>

Now that argv_split() leaves room for extra parameter, make
call_modprobe() use it.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
---
 kernel/kmod.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/kernel/kmod.c b/kernel/kmod.c
index 166aff5..70df90b 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -67,12 +67,12 @@ static DECLARE_RWSEM(umhelper_sem);
 /*
 	modprobe_path is set via /proc/sys.
 */
-char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
+char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe -q --";
 
 static void free_modprobe_argv(struct subprocess_info *info)
 {
 	kfree(info->argv[3]); /* check call_modprobe() */
-	kfree(info->argv);
+	argv_free(info->argv);
 }
 
 static int call_modprobe(char *module_name, int wait)
@@ -84,8 +84,10 @@ static int call_modprobe(char *module_name, int wait)
 		"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
 		NULL
 	};
+	int argc;
+	char **argv;
 
-	char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
+	argv = argv_split(GFP_KERNEL, modprobe_path, &argc, 1);
 	if (!argv)
 		goto out;
 
@@ -93,13 +95,8 @@ static int call_modprobe(char *module_name, int wait)
 	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;
-
-	info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
+	argv[argc] = module_name;	/* check free_modprobe_argv() */
+	info = call_usermodehelper_setup(argv[0], argv, envp, GFP_KERNEL,
 					 NULL, free_modprobe_argv, NULL);
 	if (!info)
 		goto free_module_name;
@@ -109,7 +106,7 @@ static int call_modprobe(char *module_name, int wait)
 free_module_name:
 	kfree(module_name);
 free_argv:
-	kfree(argv);
+	argv_free(argv);
 out:
 	return -ENOMEM;
 }
-- 
1.8.2.2


  reply	other threads:[~2013-05-10  4:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-10  4:15 [PATCH 1/3] argv_split(): Allow extra params Lucas De Marchi
2013-05-10  4:15 ` Lucas De Marchi [this message]
2013-05-10  4:15 ` [PATCH 3/3] init/Kconfig: Add option to set modprobe command Lucas De Marchi
2013-05-10 12:58   ` Oleg Nesterov
2013-05-10 13:12     ` Oleg Nesterov
2013-05-10 13:15     ` Lucas De Marchi
2013-05-10 15:36       ` Oleg Nesterov
2013-05-10 16:03         ` Lucas De Marchi
2013-05-10 17:10           ` Oleg Nesterov
2013-05-10 17:35             ` Oleg Nesterov
2013-05-10 17:44               ` Lucas De Marchi
2013-05-13 13:59                 ` Oleg Nesterov
2013-05-11 20:10             ` Lucas De Marchi
2013-05-13 14:16               ` Oleg Nesterov
2013-05-13 14:35                 ` [RFC] teach argv_split() to ignore the spaces surrounded by \e Oleg Nesterov
2013-05-13 16:06                   ` Colin Walters
2013-05-13 17:13                     ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368159316-31744-2-git-send-email-lucas.de.marchi@gmail.com \
    --to=lucas.de.marchi@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®