Skip to contentSkip to conversation

test_kmod: fix the lock in register_test_dev_kmod()

PATCH New [email protected] 1 participant 1 message Aug 10, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 6/21 test_kmod: fix the lock in register_test_dev_kmod()

From: Dan Carpenter <[email protected]>
Subject: test_kmod: fix the lock in register_test_dev_kmod()

We accidentally just drop the lock twice instead of taking it and then releasing it. This isn't a big issue unless you are adding more than one device to test on, and the kmod.sh doesn't do that yet, however this obviously is the correct thing to do.

[[email protected]: massaged subject, explain what happens]
Fixes 39258f448d71 ("kmod: add test driver to stress test the module loader")
Cc Colin Ian King <[email protected]>
Cc David Binderman <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Jessica Yu <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Kees Cook <[email protected]>
Cc Michal Marek <[email protected]>
Cc Miroslav Benes <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Shuah Khan <[email protected]>

---

 lib/test_kmod.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_kmod.c renamed from lib/test_kmod.c~test_kmod-fix-the-lock-in-register_test_dev_kmod +1 -1
diff -puN lib/test_kmod.c~test_kmod-fix-the-lock-in-register_test_dev_kmod lib/test_kmod.c
@@ -1146,7 +1146,7 @@ static struct kmod_test_device *register
 	struct kmod_test_device *test_dev = NULL;
 	int ret;
 
-	mutex_unlock(&reg_dev_mutex);
+	mutex_lock(&reg_dev_mutex);
 
 	/* int should suffice for number of devices, test for wrap */
 	if (unlikely(num_test_devs + 1) < 0) {

_