Skip to content

Commit a890d01

Browse files
Hao Xuaxboe
Hao Xu
authored andcommitted
io_uring: fix poll requests leaking second poll entries
For pure poll requests, it doesn't remove the second poll wait entry when it's done, neither after vfs_poll() or in the poll completion handler. We should remove the second poll wait entry. And we use io_poll_remove_double() rather than io_poll_remove_waitqs() since the latter has some redundant logic. Fixes: 88e41cf ("io_uring: add multishot mode for IORING_OP_POLL_ADD") Cc: [email protected] # 5.13+ Signed-off-by: Hao Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ef04688 commit a890d01

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/io_uring.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -4939,7 +4939,6 @@ static bool io_poll_complete(struct io_kiocb *req, __poll_t mask)
49394939
if (req->poll.events & EPOLLONESHOT)
49404940
flags = 0;
49414941
if (!io_cqring_fill_event(ctx, req->user_data, error, flags)) {
4942-
io_poll_remove_waitqs(req);
49434942
req->poll.done = true;
49444943
flags = 0;
49454944
}
@@ -4962,6 +4961,7 @@ static void io_poll_task_func(struct io_kiocb *req)
49624961

49634962
done = io_poll_complete(req, req->result);
49644963
if (done) {
4964+
io_poll_remove_double(req);
49654965
hash_del(&req->hash_node);
49664966
} else {
49674967
req->result = 0;
@@ -5149,7 +5149,7 @@ static __poll_t __io_arm_poll_handler(struct io_kiocb *req,
51495149
ipt->error = -EINVAL;
51505150

51515151
spin_lock_irq(&ctx->completion_lock);
5152-
if (ipt->error)
5152+
if (ipt->error || (mask && (poll->events & EPOLLONESHOT)))
51535153
io_poll_remove_double(req);
51545154
if (likely(poll->head)) {
51555155
spin_lock(&poll->head->lock);
@@ -5221,7 +5221,6 @@ static int io_arm_poll_handler(struct io_kiocb *req)
52215221
ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask,
52225222
io_async_wake);
52235223
if (ret || ipt.error) {
5224-
io_poll_remove_double(req);
52255224
spin_unlock_irq(&ctx->completion_lock);
52265225
if (ret)
52275226
return IO_APOLL_READY;

0 commit comments

Comments
 (0)