From c1d8a196a5f2c8a517ba27b5dd145099a910c68e Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Sun, 5 May 2019 16:50:19 +0800 Subject: [PATCH] block: pass no-op callback to INIT_WORK(). mainline inclusion from mainline-5.0-rc5 commit 2e3c18d0ada16f145087b2687afcad1748c0827c category: bugfix bugzilla: 14007 CVE: NA --------------------------- syzbot is hitting flush_work() warning caused by commit 4d43d395fed12463 ("workqueue: Try to catch flush_work() without INIT_WORK().") [1]. Although that commit did not expect INIT_WORK(NULL) case, calling flush_work() without setting a valid callback should be avoided anyway. Fix this problem by setting a no-op callback instead of NULL. [1] https://syzkaller.appspot.com/bug?id=e390366bc48bc82a7c668326e0663be3b91cbd29 Signed-off-by: Tetsuo Handa Reported-and-tested-by: syzbot Cc: Tejun Heo Signed-off-by: Jens Axboe [zhengbin: since hulk-4.19 still has blk_timeout_work which is used by blk-sq, rename the new function to blk_timeout_work_empty] Signed-off-by: zhengbin Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- block/blk-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 26d3a2f38a1c..546a115ef6b0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -983,6 +983,10 @@ static void blk_rq_timed_out_timer(struct timer_list *t) kblockd_schedule_work(&q->timeout_work); } +static void blk_timeout_work_empty(struct work_struct *work) +{ +} + /** * blk_alloc_queue_node - allocate a request queue * @gfp_mask: memory allocation flags @@ -1037,7 +1041,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id, timer_setup(&q->backing_dev_info->laptop_mode_wb_timer, laptop_mode_timer_fn, 0); timer_setup(&q->timeout, blk_rq_timed_out_timer, 0); - INIT_WORK(&q->timeout_work, NULL); + INIT_WORK(&q->timeout_work, blk_timeout_work_empty); INIT_LIST_HEAD(&q->timeout_list); INIT_LIST_HEAD(&q->icq_list); #ifdef CONFIG_BLK_CGROUP -- GitLab