]> www.infradead.org Git - users/hch/misc.git/commitdiff
do_change_type(): use guards
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Aug 2025 00:16:46 +0000 (20:16 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:56 +0000 (19:35 -0400)
clean fit; namespace_excl to modify propagation graph

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

index f1460ddd1486ecb205d577edb87b24399e93a502..a6a7b068770a4364d1d76f6eb7e21449898718e7 100644 (file)
@@ -2899,7 +2899,7 @@ static int do_change_type(struct path *path, int ms_flags)
        struct mount *mnt = real_mount(path->mnt);
        int recurse = ms_flags & MS_REC;
        int type;
-       int err = 0;
+       int err;
 
        if (!path_mounted(path))
                return -EINVAL;
@@ -2908,23 +2908,22 @@ static int do_change_type(struct path *path, int ms_flags)
        if (!type)
                return -EINVAL;
 
-       namespace_lock();
+       guard(namespace_excl)();
+
        err = may_change_propagation(mnt);
        if (err)
-               goto out_unlock;
+               return err;
 
        if (type == MS_SHARED) {
                err = invent_group_ids(mnt, recurse);
                if (err)
-                       goto out_unlock;
+                       return err;
        }
 
        for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
                change_mnt_propagation(m, type);
 
- out_unlock:
-       namespace_unlock();
-       return err;
+       return 0;
 }
 
 /* may_copy_tree() - check if a mount tree can be copied