diff --git a/fs/io_uring.c b/fs/io_uring.c
index da61eeaf64e88e636e5ff61f5a9895e9f3368a23..d07388600bbedb8457e7fe14bd1ec4569fb7369f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8669,6 +8669,18 @@ static bool io_register_op_must_quiesce(int op)
 	}
 }
 
+static void io_refs_resurrect(struct percpu_ref *ref, struct completion *compl)
+{
+	bool got = percpu_ref_tryget(ref);
+
+	/* already at zero, wait for ->release() */
+	if (!got)
+		wait_for_completion(compl);
+	percpu_ref_resurrect(ref);
+	if (got)
+		percpu_ref_put(ref);
+}
+
 static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 			       void __user *arg, unsigned nr_args)
 	__releases(ctx->uring_lock)
@@ -8699,9 +8711,8 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 		ret = wait_for_completion_interruptible(&ctx->ref_comp);
 		mutex_lock(&ctx->uring_lock);
 		if (ret) {
-			percpu_ref_resurrect(&ctx->refs);
-			ret = -EINTR;
-			goto out;
+			io_refs_resurrect(&ctx->refs, &ctx->ref_comp);
+			return ret;
 		}
 	}
 
@@ -8772,7 +8783,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
 	if (io_register_op_must_quiesce(opcode)) {
 		/* bring the ctx back to life */
 		percpu_ref_reinit(&ctx->refs);
-out:
 		reinit_completion(&ctx->ref_comp);
 	}
 	return ret;