summaryrefslogtreecommitdiff
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2014-09-12 20:56:04 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-10-05 14:52:22 -0700
commit192ffa5bb712446637fbf738b726a4fb873a7aac (patch)
treee4b9355ce3d90cbbd6bbaa7924ed99b37ef9d665 /fs/gfs2/inode.c
parent0d67673fea1c9a8910431f7cffeb5ff4b7fd2c8c (diff)
GFS2: fix d_splice_alias() misuses
commit cfb2f9d5c921e38b0f12bb26fed10b877664444d upstream. 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. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/gfs2/inode.c')
-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 5c524180c98e..bc643b97423c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -606,8 +606,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
if (!IS_ERR(inode)) {
d = d_splice_alias(inode, dentry);
error = PTR_ERR(d);
- if (IS_ERR(d))
+ if (IS_ERR(d)) {
+ inode = ERR_CAST(d);
goto fail_gunlock;
+ }
error = 0;
if (file) {
if (S_ISREG(inode->i_mode)) {
@@ -823,7 +825,6 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
d = d_splice_alias(inode, dentry);
if (IS_ERR(d)) {
- iput(inode);
gfs2_glock_dq_uninit(&gh);
return d;
}