aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2014-09-12 15:56:04 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2014-09-12 15:58:55 -0400
commitcfb2f9d5c921e38b0f12bb26fed10b877664444d (patch)
treec48f758a0b66ec32d15e4ff5a42334a72889a1b5 /fs/gfs2
parenta937cca270c544c4319572b57b196b2251b07dd2 (diff)
GFS2: fix d_splice_alias() misuses
Callers of d_splice_alias(dentry, inode) don't need iput(), neither on success nor on failure. Either the reference to inode is stored in a previously negative dentry, or it's dropped. In either case inode reference the caller used to hold is consumed. __gfs2_lookup() does iput() in case when d_splice_alias() has failed. Double iput() if we ever hit that. And gfs2_create_inode() ends up not only with double iput(), but with link count dropped to zero - on an inode it has just found in directory. Cc: stable@vger.kernel.org # v3.14+ Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/inode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 9317ddc1b3c3..fc8ac2ee0667 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -626,8 +626,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
626 if (!IS_ERR(inode)) { 626 if (!IS_ERR(inode)) {
627 d = d_splice_alias(inode, dentry); 627 d = d_splice_alias(inode, dentry);
628 error = PTR_ERR(d); 628 error = PTR_ERR(d);
629 if (IS_ERR(d)) 629 if (IS_ERR(d)) {
630 inode = ERR_CAST(d);
630 goto fail_gunlock; 631 goto fail_gunlock;
632 }
631 error = 0; 633 error = 0;
632 if (file) { 634 if (file) {
633 if (S_ISREG(inode->i_mode)) { 635 if (S_ISREG(inode->i_mode)) {
@@ -856,7 +858,6 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
856 858
857 d = d_splice_alias(inode, dentry); 859 d = d_splice_alias(inode, dentry);
858 if (IS_ERR(d)) { 860 if (IS_ERR(d)) {
859 iput(inode);
860 gfs2_glock_dq_uninit(&gh); 861 gfs2_glock_dq_uninit(&gh);
861 return d; 862 return d;
862 } 863 }