]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
autofs: convert autofs_dev_ioctl_open_mountpoint() to FD_ADD()
authorChristian Brauner <brauner@kernel.org>
Sun, 23 Nov 2025 16:33:29 +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-11-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/autofs/dev-ioctl.c

index d8dd150cbd7489a9230ac0f8ce6ccbfd9ee9fef1..ff67cd77681203ffa3106c2897b6bda1d165e69b 100644 (file)
@@ -231,32 +231,14 @@ static int test_by_type(const struct path *path, void *p)
  */
 static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
 {
-       int err, fd;
-
-       fd = get_unused_fd_flags(O_CLOEXEC);
-       if (likely(fd >= 0)) {
-               struct file *filp;
-               struct path path;
-
-               err = find_autofs_mount(name, &path, test_by_dev, &devid);
-               if (err)
-                       goto out;
-
-               filp = dentry_open(&path, O_RDONLY, current_cred());
-               path_put(&path);
-               if (IS_ERR(filp)) {
-                       err = PTR_ERR(filp);
-                       goto out;
-               }
-
-               fd_install(fd, filp);
-       }
+       struct path path __free(path_put) = {};
+       int err;
 
-       return fd;
+       err = find_autofs_mount(name, &path, test_by_dev, &devid);
+       if (err)
+               return err;
 
-out:
-       put_unused_fd(fd);
-       return err;
+       return FD_ADD(O_CLOEXEC, dentry_open(&path, O_RDONLY, current_cred()));
 }
 
 /* Open a file descriptor on an autofs mount point */