Skip to content

Commit 2f8229d

Browse files
committed
io_uring/waitid: always prune wait queue entry in io_waitid_wait()
For a successful return, always remove our entry from the wait queue entry list. Previously this was skipped if a cancelation was in progress, but this can race with another invocation of the wait queue entry callback. Cc: [email protected] Fixes: f31ecf6 ("io_uring: add IORING_OP_WAITID support") Reported-by: [email protected] Tested-by: [email protected] Link: https://lore.kernel.org/io-uring/[email protected]/ Signed-off-by: Jens Axboe <[email protected]>
1 parent 0ca2864 commit 2f8229d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

io_uring/waitid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,14 @@ static int io_waitid_wait(struct wait_queue_entry *wait, unsigned mode,
230230
if (!pid_child_should_wake(wo, p))
231231
return 0;
232232

233+
list_del_init(&wait->entry);
234+
233235
/* cancel is in progress */
234236
if (atomic_fetch_inc(&iw->refs) & IO_WAITID_REF_MASK)
235237
return 1;
236238

237239
req->io_task_work.func = io_waitid_cb;
238240
io_req_task_work_add(req);
239-
list_del_init(&wait->entry);
240241
return 1;
241242
}
242243

0 commit comments

Comments
 (0)