[PATCH] workqueue: detect uninitated work_struct and BUG() if true

From: Du, Changbin
Date: Mon Mar 09 2015 - 00:06:43 EST

Recently I encounter a driver issue that caused by missing initializing
the work_struct. Then the work never get executed and stay in workqueue
forever. This take me some time to locate the error. This issue can be
seen early if detect it when queuing a work.

Signed-off-by: Du, Changbin <changbin.du@xxxxxxxxx>
kernel/workqueue.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index f288493..5c1a5bc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1295,6 +1295,9 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,

+ if (!work->func)
+ BUG();

/* if draining, only works from the same workqueue are allowed */

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/