fhandle: reflow get_path_anchor()
authorChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 08:29:08 +0000 (10:29 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 24 Jun 2025 13:45:37 +0000 (15:45 +0200)
Switch to a more common coding style.

Link: https://lore.kernel.org/20250624-work-pidfs-fhandle-v2-5-d02a04858fe3@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/fhandle.c

index d8d32208c621106d8cc5e617dc1e5e5118202664..9ef35f8e898976315621c3abaf3c5ef9c6264018 100644 (file)
@@ -170,21 +170,25 @@ SYSCALL_DEFINE5(name_to_handle_at, int, dfd, const char __user *, name,
 
 static int get_path_anchor(int fd, struct path *root)
 {
+       if (fd >= 0) {
+               CLASS(fd, f)(fd);
+               if (fd_empty(f))
+                       return -EBADF;
+               *root = fd_file(f)->f_path;
+               path_get(root);
+               return 0;
+       }
+
        if (fd == AT_FDCWD) {
                struct fs_struct *fs = current->fs;
                spin_lock(&fs->lock);
                *root = fs->pwd;
                path_get(root);
                spin_unlock(&fs->lock);
-       } else {
-               CLASS(fd, f)(fd);
-               if (fd_empty(f))
-                       return -EBADF;
-               *root = fd_file(f)->f_path;
-               path_get(root);
+               return 0;
        }
 
-       return 0;
+       return -EBADF;
 }
 
 static int vfs_dentry_acceptable(void *context, struct dentry *dentry)