Skip to content

Commit

Permalink
fix inode leaks on d_splice_alias() failure exits
Browse files Browse the repository at this point in the history
d_splice_alias() callers expect it to either stash the inode reference
into a new alias, or drop the inode reference.  That makes it possible
to just return d_splice_alias() result from ->lookup() instance, without
any extra housekeeping required.

Unfortunately, that should include the failure exits.  If d_splice_alias()
returns an error, it leaves the dentry it has been given negative and
thus it *must* drop the inode reference.  Easily fixed, but it goes way
back and will need backporting.

Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Oct 24, 2014
1 parent f114040 commit 51486b9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,11 +2673,13 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
if (!IS_ROOT(new)) {
spin_unlock(&inode->i_lock);
dput(new);
iput(inode);
return ERR_PTR(-EIO);
}
if (d_ancestor(new, dentry)) {
spin_unlock(&inode->i_lock);
dput(new);
iput(inode);
return ERR_PTR(-EIO);
}
write_seqlock(&rename_lock);
Expand Down

0 comments on commit 51486b9

Please sign in to comment.