All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: lucas.de.marchi@gmail.com
Cc: David Howells <dhowells@redhat.com>,
	James Morris <james.l.morris@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Lucas De Marchi <lucas.demarchi@profusion.mobi>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/7] kmod: split call to call_usermodehelper_fns()
Date: Fri,  8 Mar 2013 03:15:09 -0300	[thread overview]
Message-ID: <1362723313-839-4-git-send-email-lucas.demarchi@profusion.mobi> (raw)
In-Reply-To: <1362723313-839-1-git-send-email-lucas.demarchi@profusion.mobi>

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>
---
 kernel/kmod.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/kernel/kmod.c b/kernel/kmod.c
index b39f240..2fd6222 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -77,6 +77,8 @@ static void free_modprobe_argv(struct subprocess_info *info)
 
 static int call_modprobe(char *module_name, int wait)
 {
+	struct subprocess_info *info;
+	gfp_t gfp_mask;
 	static char *envp[] = {
 		"HOME=/",
 		"TERM=linux",
@@ -98,8 +100,17 @@ static int call_modprobe(char *module_name, int wait)
 	argv[3] = module_name;	/* check free_modprobe_argv() */
 	argv[4] = NULL;
 
-	return call_usermodehelper_fns(modprobe_path, argv, envp,
-		wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
+	gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
+	info = call_usermodehelper_setup(modprobe_path, argv, envp,
+					 gfp_mask, 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:
 	kfree(argv);
 out:
-- 
1.8.1.5


  parent reply	other threads:[~2013-03-08  6:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08  6:15 [PATCH v2 0/7] kmod/usermodehelper changes Lucas De Marchi
2013-03-08  6:15 ` [PATCH v2 1/7] kernel/sys.c: Use the simpler call_usermodehelper() Lucas De Marchi
2013-03-09 20:17   ` Oleg Nesterov
2013-03-08  6:15 ` [PATCH v2 2/7] usermodehelper: Export _exec() and _setup() functions Lucas De Marchi
2013-03-09 20:21   ` Oleg Nesterov
2013-03-08  6:15 ` Lucas De Marchi [this message]
2013-03-09 20:23   ` [PATCH v2 3/7] kmod: split call to call_usermodehelper_fns() Oleg Nesterov
2013-03-09 23:54     ` Lucas De Marchi
2013-03-08  6:15 ` [PATCH v2 4/7] KEYS: " Lucas De Marchi
2013-03-09 20:25   ` Oleg Nesterov
2013-03-09 23:55     ` Lucas De Marchi
2013-03-25 12:55   ` David Howells
2013-03-25 13:11     ` Lucas De Marchi
2013-03-08  6:15 ` [PATCH v2 5/7] coredump: remove trailling whitespaces Lucas De Marchi
2013-03-08  6:15 ` [PATCH v2 6/7] Split remaining calls to call_usermodehelper_fns() Lucas De Marchi
2013-03-09 20:42   ` Oleg Nesterov
2013-03-09 23:57     ` Lucas De Marchi
2013-03-08  6:15 ` [PATCH v2 7/7] kmod: remove call_usermodehelper_fns() Lucas De Marchi

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=1362723313-839-4-git-send-email-lucas.demarchi@profusion.mobi \
    --to=lucas.demarchi@profusion.mobi \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=james.l.morris@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.