io_uring: assign file_slot prior to calling io_sqe_file_register()
authorJens Axboe <axboe@kernel.dk>
Thu, 11 Feb 2021 14:45:08 +0000 (07:45 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 11 Feb 2021 14:45:08 +0000 (07:45 -0700)
We use the assigned slot in io_sqe_file_register(), and a previous
patch moved the assignment to after we have called it. This isn't
super pretty, and will get cleaned up in the future. For now, fix
the regression by restoring the previous assignment/clear of the
file_slot.

Fixes: ea64ec02b31d ("io_uring: deduplicate file table slot calculation")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index f730af32c17ab9e9de6f4367e6ebe252e88c5a1c..cd9c4c05f6f5f4a7fa1b4dd87a25d9d7064141db 100644 (file)
@@ -8112,12 +8112,13 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
                                err = -EBADF;
                                break;
                        }
+                       *file_slot = file;
                        err = io_sqe_file_register(ctx, file, i);
                        if (err) {
+                               *file_slot = NULL;
                                fput(file);
                                break;
                        }
-                       *file_slot = file;
                }
        }