[PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload
From: Joel Fernandes (Google)
Date: Fri Apr 24 2020 - 18:36:42 EST
Kthread running the test needs to be stopped or it can continue
executing code unloaded by module causing a crash.
Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Reported-by: Xiao Yang <yangx.jy@xxxxxxxxxxxxxx>
Link: http://lore.kernel.org/r/5EA2B0C8.2080706@xxxxxxxxxxxxxx
Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
kernel/trace/preemptirq_delay_test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
index 31c0fad4cb9e1..1c28ca20e30b6 100644
--- a/kernel/trace/preemptirq_delay_test.c
+++ b/kernel/trace/preemptirq_delay_test.c
@@ -145,10 +145,10 @@ static struct attribute_group attr_group = {
};
static struct kobject *preemptirq_delay_kobj;
+static struct task_struct *test_task;
static int __init preemptirq_delay_init(void)
{
- struct task_struct *test_task;
int retval;
test_task = preemptirq_start_test();
@@ -171,6 +171,9 @@ static int __init preemptirq_delay_init(void)
static void __exit preemptirq_delay_exit(void)
{
kobject_put(preemptirq_delay_kobj);
+
+ if (test_task)
+ kthread_stop(test_task);
}
module_init(preemptirq_delay_init)
--
2.26.2.303.gf8c07b1a785-goog