]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nsfs: convert open_namespace() to FD_PREPARE()
authorChristian Brauner <brauner@kernel.org>
Sun, 23 Nov 2025 16:33:27 +0000 (17:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Nov 2025 11:42:32 +0000 (12:42 +0100)
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-9-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/nsfs.c

index 648dc59bef7f2456f963f0c55c38a36102c3141b..339497b1c267abdd48d12ae4550c5d02adf452f5 100644 (file)
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -108,7 +108,6 @@ int ns_get_path(struct path *path, struct task_struct *task,
 int open_namespace(struct ns_common *ns)
 {
        struct path path __free(path_put) = {};
-       struct file *f;
        int err;
 
        /* call first to consume reference */
@@ -116,16 +115,7 @@ int open_namespace(struct ns_common *ns)
        if (err < 0)
                return err;
 
-       CLASS(get_unused_fd, fd)(O_CLOEXEC);
-       if (fd < 0)
-               return fd;
-
-       f = dentry_open(&path, O_RDONLY, current_cred());
-       if (IS_ERR(f))
-               return PTR_ERR(f);
-
-       fd_install(fd, f);
-       return take_fd(fd);
+       return FD_ADD(O_CLOEXEC, dentry_open(&path, O_RDONLY, current_cred()));
 }
 
 int open_related_ns(struct ns_common *ns,