aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2013-09-23 08:21:04 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2013-09-23 08:30:57 -0400
commit5ca1db41ecdeb0358b968265fadb755213558a85 (patch)
tree870f18958af3186798422a600147bbe480b9d66c /fs/gfs2
parent149ed7f51e279916e7a7a1eef5cec50da67d7cfe (diff)
GFS2: fix dentry leaks
We need to dput() the result of d_splice_alias(), unless it is passed to finish_no_open(). Edited by Steven Whitehouse in order to make it apply to the current GFS2 git tree, and taking account of a prerequisite patch which hasn't been applied. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/inode.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 6d7f976aa328..cd58611912f5 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -585,12 +585,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
585 d = d_splice_alias(inode, dentry); 585 d = d_splice_alias(inode, dentry);
586 error = 0; 586 error = 0;
587 if (file) { 587 if (file) {
588 if (d == NULL) 588 if (S_ISREG(inode->i_mode)) {
589 d = dentry; 589 WARN_ON(d != NULL);
590 if (S_ISREG(inode->i_mode)) 590 error = finish_open(file, dentry, gfs2_open_common, opened);
591 error = finish_open(file, d, gfs2_open_common, opened); 591 } else {
592 else
593 error = finish_no_open(file, d); 592 error = finish_no_open(file, d);
593 }
594 } else {
595 dput(d);
594 } 596 }
595 gfs2_glock_dq_uninit(ghs); 597 gfs2_glock_dq_uninit(ghs);
596 return error; 598 return error;
@@ -777,8 +779,10 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
777 error = finish_open(file, dentry, gfs2_open_common, opened); 779 error = finish_open(file, dentry, gfs2_open_common, opened);
778 780
779 gfs2_glock_dq_uninit(&gh); 781 gfs2_glock_dq_uninit(&gh);
780 if (error) 782 if (error) {
783 dput(d);
781 return ERR_PTR(error); 784 return ERR_PTR(error);
785 }
782 return d; 786 return d;
783} 787}
784 788
@@ -1159,14 +1163,16 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
1159 d = __gfs2_lookup(dir, dentry, file, opened); 1163 d = __gfs2_lookup(dir, dentry, file, opened);
1160 if (IS_ERR(d)) 1164 if (IS_ERR(d))
1161 return PTR_ERR(d); 1165 return PTR_ERR(d);
1162 if (d == NULL) 1166 if (d != NULL)
1163 d = dentry; 1167 dentry = d;
1164 if (d->d_inode) { 1168 if (dentry->d_inode) {
1165 if (!(*opened & FILE_OPENED)) 1169 if (!(*opened & FILE_OPENED))
1166 return finish_no_open(file, d); 1170 return finish_no_open(file, dentry);
1171 dput(d);
1167 return 0; 1172 return 0;
1168 } 1173 }
1169 1174
1175 BUG_ON(d != NULL);
1170 if (!(flags & O_CREAT)) 1176 if (!(flags & O_CREAT))
1171 return -ENOENT; 1177 return -ENOENT;
1172 1178