]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring: move ctx->restricted check into io_check_restriction()
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Jan 2026 15:14:44 +0000 (08:14 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 13 Jan 2026 17:31:48 +0000 (10:31 -0700)
Just a cleanup, makes the code easier to read without too many dependent
nested checks.

Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index a1dd1540ab79d45bf34f8de3555eeca4aa01681a..92ed92a44023dbd99adf9387a30cfd0827688ada 100644 (file)
@@ -2056,6 +2056,8 @@ static inline bool io_check_restriction(struct io_ring_ctx *ctx,
                                        struct io_kiocb *req,
                                        unsigned int sqe_flags)
 {
+       if (!ctx->restricted)
+               return true;
        if (!test_bit(req->opcode, ctx->restrictions.sqe_op))
                return false;
 
@@ -2158,7 +2160,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
                }
        }
        if (unlikely(ctx->restricted || ctx->drain_active || ctx->drain_next)) {
-               if (ctx->restricted && !io_check_restriction(ctx, req, sqe_flags))
+               if (!io_check_restriction(ctx, req, sqe_flags))
                        return io_init_fail_req(req, -EACCES);
                /* knock it to the slow queue path, will be drained there */
                if (ctx->drain_active)