diff mbox series

[1/4] fs: use semaphore gard in listmount()

Message ID 20240607-vfs-listmount-reverse-v1-1-7877a2bfa5e5@kernel.org (mailing list archive)
State New
Headers show
Series fs: allow listmount() with reversed ordering | expand

Commit Message

Christian Brauner June 7, 2024, 2:55 p.m. UTC
Instead of open-coding the locking use a guard.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/namespace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/namespace.c b/fs/namespace.c
index 5a51315c6678..72c6e884728b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -5106,7 +5106,8 @@  SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req, u64 __user *,
 	mnt_parent_id = kreq.mnt_id;
 	last_mnt_id = kreq.param;
 
-	down_read(&namespace_sem);
+	guard(rwsem_read)(&namespace_sem);
+
 	get_fs_root(current->fs, &root);
 	if (mnt_parent_id == LSMT_ROOT) {
 		orig = root;
@@ -5125,7 +5126,6 @@  SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req, u64 __user *,
 	ret = do_listmount(first, &orig, mnt_parent_id, mnt_ids, nr_mnt_ids, &root);
 err:
 	path_put(&root);
-	up_read(&namespace_sem);
 	return ret;
 }