From: Johannes Berg <johannes.berg@xxxxxxxxx> In flush_work(), we need to create a lockdep dependency so that the following scenario is appropriately tagged as a problem: work_function() { mutex_lock(&mutex); ... } other_function() { mutex_lock(&mutex); flush_work(&work); // or cancel_work_sync(&work); } This is a problem since the work might be running and be blocked on trying to acquire the mutex. Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> --- kernel/workqueue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index a6c2b823f348..29d4d84ba512 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2852,6 +2852,11 @@ static bool start_flush_work(struct work_struct *work, struct wq_barrier *barr, might_sleep(); + if (!from_cancel) { + lock_map_acquire(&work->lockdep_map); + lock_map_release(&work->lockdep_map); + } + local_irq_disable(); pool = get_work_pool(work); if (!pool) { -- 2.14.4