From: Zhang Qiang <qiang.zh...@windriver.com>

Before the work is put into the queue of the worker thread,
the state of the worker thread needs to be detected,because
the worker thread may be in the destruction state at this time.

Signed-off-by: Zhang Qiang <qiang.zh...@windriver.com>
Suggested-by: Petr Mladek <pmla...@suse.com>
Reviewed-by: Petr Mladek <pmla...@suse.com>
---
 v1->v2:
 Add warning information for condition "!worker->task".
 v2->v3:
 Modify submission information and add "Reviewed-by" tags.
 v3->v4:
 Fix spi controller register trigger Warning.
 when a spi controller register, a "kthread_worker_fn" worker is created
 through "kthread_run" instead of "kthread_create_worker" which in this
 func the "worker->task" will be initialized. and then the "spi_start_queue"
 func queue a work to worker queue, at this time, if the worker has not
 begin to running, the "!worker->task" will be true, so a warning is triggered.

 kernel/kthread.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index bfbfa481be3a..825bd4dcdb95 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -791,6 +791,11 @@ static inline bool queuing_blocked(struct kthread_worker 
*worker,
 {
        lockdep_assert_held(&worker->lock);
 
+       if (kthread_should_stop()) {
+               WARN_ON(1);
+               return true;
+       }
+
        return !list_empty(&work->node) || work->canceling;
 }
 
-- 
2.24.1

Reply via email to