]> www.infradead.org Git - users/hch/misc.git/commitdiff
do_loopback(): use __free(path_put) to deal with old_path
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 22 Aug 2025 02:28:51 +0000 (22:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:58 +0000 (19:35 -0400)
preparations for making unlock_mount() a __cleanup();
can't have path_put() inside mount_lock scope.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c

index bdb33270ac6e3d6972e29bf6914a578c1e7fc5a7..245cf2d19a6b0f8f2f650eb97b8609855ccde8fa 100644 (file)
@@ -3014,7 +3014,7 @@ static struct mount *__do_loopback(struct path *old_path, int recurse)
 static int do_loopback(struct path *path, const char *old_name,
                                int recurse)
 {
-       struct path old_path;
+       struct path old_path __free(path_put) = {};
        struct mount *mnt = NULL, *parent;
        struct pinned_mountpoint mp = {};
        int err;
@@ -3024,13 +3024,12 @@ static int do_loopback(struct path *path, const char *old_name,
        if (err)
                return err;
 
-       err = -EINVAL;
        if (mnt_ns_loop(old_path.dentry))
-               goto out;
+               return -EINVAL;
 
        err = lock_mount(path, &mp);
        if (err)
-               goto out;
+               return err;
 
        parent = real_mount(path->mnt);
        if (!check_mnt(parent))
@@ -3050,8 +3049,6 @@ static int do_loopback(struct path *path, const char *old_name,
        }
 out2:
        unlock_mount(&mp);
-out:
-       path_put(&old_path);
        return err;
 }