Skip to contentSkip to conversation

kmod: test_kmod: Correctly lock reg_dev_mutex

PATCH In review Daniel Mentz 2 participants 4 messages Aug 8, 2017 – Aug 9, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kmod: test_kmod: Correctly lock reg_dev_mutex

It appears that, in the preamble of register_test_dev_kmod(), mutex_lock() has been confused with mutex_unlock().

Previously, register_test_dev_kmod() never called mutex_lock() but instead, it called mutex_unlock() twice.

Cc Luis R. Rodriguez <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>
---
 lib/test_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_kmod.c +1 -1
index 6c1d678bcf8b..f458130a5e65 100644
@@ -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) {
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
#1 lore raw
Quoted 11 lines · Daniel Mentz

It appears that, in the preamble of register_test_dev_kmod(), mutex_lock() has been confused with mutex_unlock().

Previously, register_test_dev_kmod() never called mutex_lock() but instead, it called mutex_unlock() twice.

Cc Luis R. Rodriguez <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>

---

Thanks Daniel but someone beat you to the fix, I've sent this to Andrew and he's integrated into his -mm tree. See:

http://lkml.kernel.org/r/[email protected]

This series had other fixes:

https://marc.info/?l=linux-kernel&m=150170850624962&w=2

I'll CC you on other kmod / test_kmod changes.

Luis

#2 lore raw

OK. While we're here: I think there's a spelling error in usage() in tools/testing/selftests/kmod/kmod.sh

echo "    -c      Run test ID once"
echo "    -s      Run test ID x test-count number of times"

I believe that "-c" and "-s" are swapped. "c" probably stands for count and "s" for single.

#3 lore raw
Quoted 8 lines · Daniel Mentz

OK. While we're here: I think there's a spelling error in usage() in tools/testing/selftests/kmod/kmod.sh

echo "    -c      Run test ID once"
echo "    -s      Run test ID x test-count number of times"

I believe that "-c" and "-s" are swapped. "c" probably stands for count and "s" for single.

Indeed, will send a fix. Thanks!

Luis