mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCH] locktorture: fix wrong parameter handling
Date: Fri,  9 Oct 2015 14:14:45 +0200	[thread overview]
Message-ID: <1444392885-6691-1-git-send-email-borntraeger@de.ibm.com> (raw)

Calling locktorture with a wrong parameter makes it
unusable:

$ modprobe locktorture torture_type=help
modprobe: ERROR: could not insert 'locktorture': Invalid argument

$ modprobe locktorture torture_type=spin_lock
modprobe: ERROR: could not insert 'locktorture': Device or resource busy

$ dmesg
[...]
torture_init_begin: refusing spin_lock init: help running

We can easily do the checking before call into the torture framework.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 kernel/locking/locktorture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 3224418..f5f66a6 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -645,9 +645,6 @@ static int __init lock_torture_init(void)
 		&rwsem_lock_ops,
 	};
 
-	if (!torture_init_begin(torture_type, verbose, &torture_runnable))
-		return -EBUSY;
-
 	/* Process args and tell the world that the torturer is on the job. */
 	for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
 		cxt.cur_ops = torture_ops[i];
@@ -661,9 +658,12 @@ static int __init lock_torture_init(void)
 		for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
 			pr_alert(" %s", torture_ops[i]->name);
 		pr_alert("\n");
-		torture_init_end();
 		return -EINVAL;
 	}
+
+	if (!torture_init_begin(torture_type, verbose, &torture_runnable))
+		return -EBUSY;
+
 	if (cxt.cur_ops->init)
 		cxt.cur_ops->init(); /* no "goto unwind" prior to this point!!! */
 
-- 
2.4.3


             reply	other threads:[~2015-10-09 12:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 12:14 Christian Borntraeger [this message]
2015-10-09 14:46 ` Paul E. McKenney
2015-10-09 14:53   ` Christian Borntraeger
2015-10-09 15:44     ` Paul E. McKenney

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=1444392885-6691-1-git-send-email-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.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®