lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1381753562-47884-2-git-send-email-wangkefeng.wang@huawei.com>
Date:	Mon, 14 Oct 2013 20:26:00 +0800
From:	Kefeng Wang <wangkefeng.wang@...wei.com>
To:	Alexander Viro <viro@...iv.linux.org.uk>
CC:	John McCutchan <john@...nmccutchan.com>,
	"J. Bruce Fields" <bfields@...ldses.org>,
	Eric Paris <eparis@...hat.com>, Robert Love <rlove@...ve.org>,
	<linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
	<linux-nfs@...r.kernel.org>
Subject: [PATCH 1/3] fs: use path_equal() and path_put() to simplify code

Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
---
 fs/namei.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 645268f..1a6c139 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -918,9 +918,8 @@ int follow_up(struct path *path)
 	mntget(&parent->mnt);
 	mountpoint = dget(mnt->mnt_mountpoint);
 	br_read_unlock(&vfsmount_lock);
-	dput(path->dentry);
+	path_put(path);
 	path->dentry = mountpoint;
-	mntput(path->mnt);
 	path->mnt = &parent->mnt;
 	return 1;
 }
@@ -1077,8 +1076,7 @@ int follow_down_one(struct path *path)
 
 	mounted = lookup_mnt(path);
 	if (mounted) {
-		dput(path->dentry);
-		mntput(path->mnt);
+		path_put(path);
 		path->mnt = mounted;
 		path->dentry = dget(mounted->mnt_root);
 		return 1;
@@ -1146,10 +1144,8 @@ static int follow_dotdot_rcu(struct nameidata *nd)
 	set_root_rcu(nd);
 
 	while (1) {
-		if (nd->path.dentry == nd->root.dentry &&
-		    nd->path.mnt == nd->root.mnt) {
+		if (path_equal(&nd->path, &nd->root))
 			break;
-		}
 		if (nd->path.dentry != nd->path.mnt->mnt_root) {
 			struct dentry *old = nd->path.dentry;
 			struct dentry *parent = old->d_parent;
@@ -1214,8 +1210,7 @@ int follow_down(struct path *path)
 			struct vfsmount *mounted = lookup_mnt(path);
 			if (!mounted)
 				break;
-			dput(path->dentry);
-			mntput(path->mnt);
+			path_put(path);
 			path->mnt = mounted;
 			path->dentry = dget(mounted->mnt_root);
 			continue;
@@ -1236,8 +1231,7 @@ static void follow_mount(struct path *path)
 		struct vfsmount *mounted = lookup_mnt(path);
 		if (!mounted)
 			break;
-		dput(path->dentry);
-		mntput(path->mnt);
+		path_put(path);
 		path->mnt = mounted;
 		path->dentry = dget(mounted->mnt_root);
 	}
@@ -1250,10 +1244,8 @@ static void follow_dotdot(struct nameidata *nd)
 	while(1) {
 		struct dentry *old = nd->path.dentry;
 
-		if (nd->path.dentry == nd->root.dentry &&
-		    nd->path.mnt == nd->root.mnt) {
+		if (path_equal(&nd->path, &nd->root))
 			break;
-		}
 		if (nd->path.dentry != nd->path.mnt->mnt_root) {
 			/* rare case of legitimate dget_parent()... */
 			nd->path.dentry = dget_parent(nd->path.dentry);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ