From: Al Viro Date: Thu, 21 Aug 2025 00:12:47 +0000 (-0400) Subject: __detach_mounts(): use guards X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=902e9904672bedcb25c6740d5c1d09e17de807eb;p=users%2Fhch%2Fmisc.git __detach_mounts(): use guards Clean fit for guards use; guards can't be weaker due to umount_tree() calls. Reviewed-by: Christian Brauner Signed-off-by: Al Viro --- diff --git a/fs/namespace.c b/fs/namespace.c index 767ab751ee2a..1ae1ab8815c9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2032,10 +2032,11 @@ void __detach_mounts(struct dentry *dentry) struct pinned_mountpoint mp = {}; struct mount *mnt; - namespace_lock(); - lock_mount_hash(); + guard(namespace_excl)(); + guard(mount_writer)(); + if (!lookup_mountpoint(dentry, &mp)) - goto out_unlock; + return; event++; while (mp.node.next) { @@ -2047,9 +2048,6 @@ void __detach_mounts(struct dentry *dentry) else umount_tree(mnt, UMOUNT_CONNECTED); } unpin_mountpoint(&mp); -out_unlock: - unlock_mount_hash(); - namespace_unlock(); } /*