From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754060AbbJIMO1 (ORCPT ); Fri, 9 Oct 2015 08:14:27 -0400 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:43791 "EHLO e06smtp06.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753943AbbJIMOZ (ORCPT ); Fri, 9 Oct 2015 08:14:25 -0400 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: borntraeger@de.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org From: Christian Borntraeger To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Christian Borntraeger Subject: [PATCH] locktorture: fix wrong parameter handling Date: Fri, 9 Oct 2015 14:14:45 +0200 Message-Id: <1444392885-6691-1-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 2.4.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15100912-0025-0000-0000-0000047CD226 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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