Skip to content

Commit

Permalink
GFS2: fix d_splice_alias() misuses
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro authored and Steven Whitehouse committed Sep 12, 2014
1 parent a937cca commit cfb2f9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,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)) {
Expand Down Expand Up @@ -856,7 +858,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;
}
Expand Down

0 comments on commit cfb2f9d

Please sign in to comment.