[PATCH v2] kthread: work could not be queued when worker being destroyed

From: qiang.zhang
Date: Fri Jul 03 2020 - 04:49:14 EST


From: Zhang Qiang <qiang.zhang@xxxxxxxxxxxxx>

The "queuing_blocked" func should print warning message and
returns true when the worker being destroyed.

Suggested-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Zhang Qiang <qiang.zhang@xxxxxxxxxxxxx>
---
v1->v2:
Add warning information for condition "!worker->task"

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

diff --git a/kernel/kthread.c b/kernel/kthread.c
index bfbfa481be3a..cac5184ffd86 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -791,6 +791,9 @@ static inline bool queuing_blocked(struct kthread_worker *worker,
{
lockdep_assert_held(&worker->lock);

+ if (WARN_ON(!worker->task))
+ return true;
+
return !list_empty(&work->node) || work->canceling;
}

--
2.24.1