[patch 10/47] ecryptfs: clean up (un)lock_parent

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Friday, June 13, 2008 - 5:10 pm

-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Miklos Szeredi <mszeredi@suse.cz>

upstream commit: 8dc4e37362a5dc910d704d52ac6542bfd49ddc2f

dget(dentry->d_parent) --> dget_parent(dentry)

unlock_parent() is racy and unnecessary.  Replace single caller with
unlock_dir().

There are several other suspect uses of ->d_parent in ecryptfs...

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 fs/ecryptfs/inode.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -37,17 +37,11 @@ static struct dentry *lock_parent(struct
 {
 	struct dentry *dir;
 
-	dir = dget(dentry->d_parent);
+	dir = dget_parent(dentry);
 	mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT);
 	return dir;
 }
 
-static void unlock_parent(struct dentry *dentry)
-{
-	mutex_unlock(&(dentry->d_parent->d_inode->i_mutex));
-	dput(dentry->d_parent);
-}
-
 static void unlock_dir(struct dentry *dir)
 {
 	mutex_unlock(&dir->d_inode->i_mutex);
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode 
 	int rc = 0;
 	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
+	struct dentry *lower_dir_dentry;
 
-	lock_parent(lower_dentry);
+	lower_dir_dentry = lock_parent(lower_dentry);
 	rc = vfs_unlink(lower_dir_inode, lower_dentry);
 	if (rc) {
 		printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode 
 	dentry->d_inode->i_ctime = dir->i_ctime;
 	d_drop(dentry);
 out_unlock:
-	unlock_parent(lower_dentry);
+	unlock_dir(lower_dir_dentry);
 	return rc;
 }
 

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/47] 2.6.25-stable review, Greg KH, (Fri Jun 13, 5:08 pm)
[patch 01/47] b43: Fix controller restart crash, Greg KH, (Fri Jun 13, 5:10 pm)
[patch 02/47] ipwireless: Fix blocked sending, Greg KH, (Fri Jun 13, 5:10 pm)
[patch 10/47] ecryptfs: clean up (un)lock_parent, Greg KH, (Fri Jun 13, 5:10 pm)
[patch 11/47] ecryptfs: fix missed mutex_unlock, Greg KH, (Fri Jun 13, 5:10 pm)
[patch 35/47] cciss: add new hardware support, Greg KH, (Fri Jun 13, 5:11 pm)
[patch 36/47] hgafb: resource management fix, Greg KH, (Fri Jun 13, 5:11 pm)
[patch 37/47] forcedeth: msi interrupts, Greg KH, (Fri Jun 13, 5:11 pm)
[patch 42/47] CPUFREQ: Fix format string bug., Greg KH, (Fri Jun 13, 5:12 pm)
[patch 46/47] x86: fix recursive dependencies, Greg KH, (Fri Jun 13, 5:12 pm)