io_uring: fix race condition in task_work add and clear
[linux-2.6-microblaze.git] / fs / io_uring.c
index cb65e54..83973f6 100644 (file)
@@ -1893,10 +1893,10 @@ static void tctx_task_work(struct callback_head *cb)
 {
        struct io_uring_task *tctx = container_of(cb, struct io_uring_task, task_work);
 
+       clear_bit(0, &tctx->task_state);
+
        while (__tctx_task_work(tctx))
                cond_resched();
-
-       clear_bit(0, &tctx->task_state);
 }
 
 static int io_task_work_add(struct task_struct *tsk, struct io_kiocb *req,