Skip to content

Commit

Permalink
test_kmod: fix the lock in register_test_dev_kmod()
Browse files Browse the repository at this point in the history
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]
Link: http://lkml.kernel.org/r/[email protected]
Fixes: 39258f4 ("kmod: add test driver to stress test the module loader")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
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]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dan Carpenter authored and torvalds committed Aug 10, 2017
1 parent 434b06a commit 9c56771
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test_kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ static struct kmod_test_device *register_test_dev_kmod(void)
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) {
Expand Down

0 comments on commit 9c56771

Please sign in to comment.