Signed-off-by: Christian Brauner --- fs/namespace.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index d82910f33dc4..cff0fdc27fda 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3103,19 +3103,14 @@ static struct file *vfs_open_tree(int dfd, const char __user *filename, unsigned SYSCALL_DEFINE3(open_tree, int, dfd, const char __user *, filename, unsigned, flags) { - int fd; - struct file *file __free(fput) = NULL; - - file = vfs_open_tree(dfd, filename, flags); - if (IS_ERR(file)) - return PTR_ERR(file); + int ret; - fd = get_unused_fd_flags(flags & O_CLOEXEC); - if (fd < 0) - return fd; + FD_PREPARE(fdf, flags, vfs_open_tree(dfd, filename, flags)); + ret = ACQUIRE_ERR(fd_prepare, &fdf); + if (ret) + return ret; - fd_install(fd, no_free_ptr(file)); - return fd; + return fd_publish(fdf); } /* -- 2.47.3