From 902e9904672bedcb25c6740d5c1d09e17de807eb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 20 Aug 2025 20:12:47 -0400 Subject: [PATCH] __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 --- fs/namespace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 767ab751ee2a3..1ae1ab8815c9b 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(); } /* -- 2.47.3