linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/18] cleanups and bug fix in do_loopback()
@ 2005-11-08  2:01 Al Viro
  2005-11-08  6:59 ` Miklos Szeredi
  0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2005-11-08  2:01 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, linux-fsdevel, linuxram

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 1131401704 -0500

- check_mnt() on the source of binding should've been unconditional from
the very beginning.  My fault - as far I could've trace it, that's an
old thinko made back in 2001.  Kudos to Miklos for spotting it...
Fixed.
- code cleaned up.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

---

 fs/namespace.c |   41 ++++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 19 deletions(-)

aceb5c8912a85abd7a1a0f704bc742936cdad880
diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -661,29 +661,32 @@ static int do_loopback(struct nameidata 
 
 	down_write(&current->namespace->sem);
 	err = -EINVAL;
-	if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) {
-		err = -ENOMEM;
-		if (recurse)
-			mnt = copy_tree(old_nd.mnt, old_nd.dentry);
-		else
-			mnt = clone_mnt(old_nd.mnt, old_nd.dentry);
-	}
+	if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
+		goto out;
+
+	err = -ENOMEM;
+	if (recurse)
+		mnt = copy_tree(old_nd.mnt, old_nd.dentry);
+	else
+		mnt = clone_mnt(old_nd.mnt, old_nd.dentry);
+
+	if (!mnt)
+		goto out;
+
+	/* stop bind mounts from expiring */
+	spin_lock(&vfsmount_lock);
+	list_del_init(&mnt->mnt_expire);
+	spin_unlock(&vfsmount_lock);
 
-	if (mnt) {
-		/* stop bind mounts from expiring */
+	err = graft_tree(mnt, nd);
+	if (err) {
 		spin_lock(&vfsmount_lock);
-		list_del_init(&mnt->mnt_expire);
+		umount_tree(mnt);
 		spin_unlock(&vfsmount_lock);
+	} else
+		mntput(mnt);
 
-		err = graft_tree(mnt, nd);
-		if (err) {
-			spin_lock(&vfsmount_lock);
-			umount_tree(mnt);
-			spin_unlock(&vfsmount_lock);
-		} else
-			mntput(mnt);
-	}
-
+out:
 	up_write(&current->namespace->sem);
 	path_release(&old_nd);
 	return err;

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-10  0:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08  2:01 [PATCH 2/18] cleanups and bug fix in do_loopback() Al Viro
2005-11-08  6:59 ` Miklos Szeredi
2005-11-08  8:46   ` Ram Pai
2005-11-08  9:28     ` Miklos Szeredi
2005-11-09 19:08       ` Ram Pai
2005-11-09 21:15         ` Miklos Szeredi
2005-11-10  0:51           ` Ram Pai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).