From 1a074b61239613231b0d6cb68a33b001ca8e46ce Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 21 Apr 2026 16:44:06 -0600 Subject: [PATCH 2/2] io_uring/poll: fix backport of io_poll_add() changes The 5.15/5.10 backport of 84230ad2d2af had a few issues, due to the older poll base. Notably return value handling __io_arm_poll_handler() and in return __io_poll_add() as well. Fix them up. Reported-by: Ben Hutchings Fixes: 349ef5d2e7bf ("io_uring/poll: correctly handle io_poll_add() return value on update") Signed-off-by: Jens Axboe --- io_uring/io_uring.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 4f1dda7d68c2..cb54ebda0a8a 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -6144,26 +6144,22 @@ static int __io_poll_add(struct io_kiocb *req, unsigned int issue_flags) if (!ret && ipt.error) req_set_fail(req); ret = ret ?: ipt.error; - if (ret > 0) { + if (ret) __io_req_complete(req, issue_flags, ret, 0); - return ret; - } - return 0; + return ret; } static int io_poll_add(struct io_kiocb *req, unsigned int issue_flags) { - int ret; - - ret = __io_poll_add(req, issue_flags); - return ret < 0 ? ret : 0; + __io_poll_add(req, issue_flags); + return 0; } static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags) { struct io_ring_ctx *ctx = req->ctx; struct io_kiocb *preq; - int ret2, ret = 0; + int ret2 = -ECANCELED, ret = 0; io_ring_submit_lock(ctx, !(issue_flags & IO_URING_F_NONBLOCK)); @@ -6194,7 +6190,7 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags) preq->result = ret2; } - if (preq->result < 0) + if (ret2 < 0) req_set_fail(preq); io_req_complete(preq, preq->result); out: -- 2.53.0