From ed6930c9201cd1e00f74474da2f095796a0d82f6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 8 Oct 2020 19:09:46 -0600 Subject: [PATCH] io_uring: fix break condition for __io_uring_register() waiting Colin reports that there's unreachable code, since we only ever break if ret == 0. This is correct, and is due to a reversed logic condition in when to break or not. Break out of the loop if we don't process any task work, in that case we do want to return -EINTR. Fixes: af9c1a44f8de ("io_uring: process task work in io_uring_register()") Reported-by: Colin Ian King Signed-off-by: Jens Axboe --- fs/io_uring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 4df5b14c2e56..299c530c66f9 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9511,15 +9511,15 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, ret = wait_for_completion_interruptible(&ctx->ref_comp); if (!ret) break; - if (io_run_task_work_sig() > 0) - continue; + ret = io_run_task_work_sig(); + if (ret < 0) + break; } while (1); mutex_lock(&ctx->uring_lock); if (ret) { percpu_ref_resurrect(&ctx->refs); - ret = -EINTR; goto out_quiesce; } } -- 2.11.0