block: pass no-op callback to INIT_WORK(). [Linux 5.0]

block: pass no-op callback to INIT_WORK(). [Linux 5.0]

This Linux kernel change "block: pass no-op callback to INIT_WORK()" is included in the Linux 5.0 release. This change is authored by Tetsuo Handa <penguin-kernel [at]> on Wed Jan 30 22:21:45 2019 +0900. The commit for this change in Linux stable tree is 2e3c18d (patch).

block: pass no-op callback to INIT_WORK().

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.


Signed-off-by: Tetsuo Handa <[email protected]>
Reported-and-tested-by: syzbot <[email protected]>
Cc: Tejun Heo <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 3c5f61ce..6b78ec5 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -462,6 +462,10 @@ static void blk_rq_timed_out_timer(struct timer_list *t)

+static void blk_timeout_work(struct work_struct *work)
  * blk_alloc_queue_node - allocate a request queue
  * @gfp_mask: memory allocation flags
@@ -505,7 +509,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
            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);

Leave a Reply

Your email address will not be published. Required fields are marked *