aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2008-05-12 17:02:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-13 11:02:23 -0400
commit8dc4e37362a5dc910d704d52ac6542bfd49ddc2f (patch)
tree22f9a2e074a7718c90747bc0458845f54468d4fc /fs/ecryptfs/inode.c
parent64d032ba434ad41586460811148f01511e5612f9 (diff)
ecryptfs: clean up (un)lock_parent
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>
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 0a1397335a8e..c92cc1c00aae 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -37,17 +37,11 @@ static struct dentry *lock_parent(struct dentry *dentry)
37{ 37{
38 struct dentry *dir; 38 struct dentry *dir;
39 39
40 dir = dget(dentry->d_parent); 40 dir = dget_parent(dentry);
41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); 41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT);
42 return dir; 42 return dir;
43} 43}
44 44
45static void unlock_parent(struct dentry *dentry)
46{
47 mutex_unlock(&(dentry->d_parent->d_inode->i_mutex));
48 dput(dentry->d_parent);
49}
50
51static void unlock_dir(struct dentry *dir) 45static void unlock_dir(struct dentry *dir)
52{ 46{
53 mutex_unlock(&dir->d_inode->i_mutex); 47 mutex_unlock(&dir->d_inode->i_mutex);
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
426 int rc = 0; 420 int rc = 0;
427 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 421 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
428 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); 422 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
423 struct dentry *lower_dir_dentry;
429 424
430 lock_parent(lower_dentry); 425 lower_dir_dentry = lock_parent(lower_dentry);
431 rc = vfs_unlink(lower_dir_inode, lower_dentry); 426 rc = vfs_unlink(lower_dir_inode, lower_dentry);
432 if (rc) { 427 if (rc) {
433 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); 428 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
439 dentry->d_inode->i_ctime = dir->i_ctime; 434 dentry->d_inode->i_ctime = dir->i_ctime;
440 d_drop(dentry); 435 d_drop(dentry);
441out_unlock: 436out_unlock:
442 unlock_parent(lower_dentry); 437 unlock_dir(lower_dir_dentry);
443 return rc; 438 return rc;
444} 439}
445 440