]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/tctx: avoid modifying loop variable in io_ring_add_registered_file
authorYang Xiuwei <yangxiuwei@kylinos.cn>
Tue, 10 Feb 2026 02:34:32 +0000 (10:34 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Feb 2026 03:12:46 +0000 (20:12 -0700)
Use a separate 'idx' variable to store the result of array_index_nospec()
instead of modifying the loop variable 'offset' directly. This improves
code clarity by separating the logical index from the sanitized index
used for array access.

No functional change intended.

Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/tctx.c

index ad9e4336d73698e0f6833601b636a274b04fde06..270263699c6febb71a3fb2a3844652ebf5628ac7 100644 (file)
@@ -240,14 +240,14 @@ void io_uring_unreg_ringfd(void)
 int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file,
                                     int start, int end)
 {
-       int offset;
+       int offset, idx;
        for (offset = start; offset < end; offset++) {
-               offset = array_index_nospec(offset, IO_RINGFD_REG_MAX);
-               if (tctx->registered_rings[offset])
+               idx = array_index_nospec(offset, IO_RINGFD_REG_MAX);
+               if (tctx->registered_rings[idx])
                        continue;
 
-               tctx->registered_rings[offset] = file;
-               return offset;
+               tctx->registered_rings[idx] = file;
+               return idx;
        }
        return -EBUSY;
 }