]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io_uring: openclose: fix bug of closing wrong fixed file
authorHao Xu <howeyxu@tencent.com>
Sat, 11 Jun 2022 12:22:20 +0000 (20:22 +0800)
committerPavel Begunkov <asml.silence@gmail.com>
Mon, 13 Jun 2022 10:37:03 +0000 (11:37 +0100)
Don't update ret until fixed file is closed, otherwise the file slot
becomes the error code.

Fixes: a7c41b4687f5 ("io_uring: let IORING_OP_FILES_UPDATE support choosing fixed file slots")
Signed-off-by: Hao Xu <howeyxu@tencent.com>
[pavel: 5.19 rebase]
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
fs/io_uring.c

index fd8a1ffe6a1a2025cf67d476dacdb538f64b921f..e6d8cafdd28e6a3909626202e6c039cfcae07b68 100644 (file)
@@ -8035,8 +8035,8 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req,
                if (ret < 0)
                        break;
                if (copy_to_user(&fds[done], &ret, sizeof(ret))) {
-                       ret = -EFAULT;
                        __io_close_fixed(req, issue_flags, ret);
+                       ret = -EFAULT;
                        break;
                }
        }