* [RFC PATCH] kunit: run test suites only after module initialization completes
@ 2023-09-27 15:48 Marco Pagani
0 siblings, 0 replies; only message in thread
From: Marco Pagani @ 2023-09-27 15:48 UTC (permalink / raw)
To: Brendan Higgins, David Gow, Jinjie Ruan, Shuah Khan, Rae Moar
Cc: Marco Pagani, linux-kselftest, kunit-dev, linux-kernel
Commit 2810c1e99867 ("kunit: Fix wild-memory-access bug in
kunit_free_suite_set()") causes test suites to run while the test
module is still in MODULE_STATE_COMING. In that state, the module
is not fully initialized, lacking sysfs, module_memory, args, init
function. This behavior can cause all sorts of problems while using
fake devices.
This RFC patch restores the normal execution flow, waiting for module
initialization to complete before running the tests, and uses the
refcount to avoid calling kunit_free_suite_set() if load_module()
fails.
Fixes: 2810c1e99867 ("kunit: Fix wild-memory-access bug in kunit_free_suite_set()")
Signed-off-by: Marco Pagani <marpagan@redhat.com>
---
lib/kunit/test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 421f13981412..242f26ad387a 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -784,13 +784,13 @@ static int kunit_module_notify(struct notifier_block *nb, unsigned long val,
switch (val) {
case MODULE_STATE_LIVE:
+ kunit_module_init(mod);
break;
case MODULE_STATE_GOING:
- kunit_module_exit(mod);
+ if (module_refcount(mod) == -1)
+ kunit_module_exit(mod);
break;
case MODULE_STATE_COMING:
- kunit_module_init(mod);
- break;
case MODULE_STATE_UNFORMED:
break;
}
--
2.41.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-27 15:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 15:48 [RFC PATCH] kunit: run test suites only after module initialization completes Marco Pagani
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®