From: Eric Sandeen Date: Sat, 22 Dec 2007 22:03:26 +0000 (-0800) Subject: ecryptfs: redo dget,mntget on dentry_open failure X-Git-Tag: MMI-PSA29.97-13-9~37920 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=16317ec2e5a85884fea680d24c1b228a5602159f;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git ecryptfs: redo dget,mntget on dentry_open failure Thanks to Jeff Moyer for pointing this out. If the RDWR dentry_open() in ecryptfs_init_persistent_file fails, it will do a dput/mntput. Need to re-take references if we retry as RDONLY. Signed-off-by: Eric Sandeen Acked-by: Mike Halcrow Signed-off-by: Jeff Moyer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index a277754da171..e5580bcb923a 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -138,11 +138,14 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) inode_info->lower_file = dentry_open(lower_dentry, lower_mnt, (O_RDWR | O_LARGEFILE)); - if (IS_ERR(inode_info->lower_file)) + if (IS_ERR(inode_info->lower_file)) { + dget(lower_dentry); + mntget(lower_mnt); inode_info->lower_file = dentry_open(lower_dentry, lower_mnt, (O_RDONLY | O_LARGEFILE)); + } if (IS_ERR(inode_info->lower_file)) { printk(KERN_ERR "Error opening lower persistent file " "for lower_dentry [0x%p] and lower_mnt [0x%p]\n",