Commit 51486b90 authored by Al Viro's avatar Al Viro

fix inode leaks on d_splice_alias() failure exits

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f114040e
...@@ -2673,11 +2673,13 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) ...@@ -2673,11 +2673,13 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
if (!IS_ROOT(new)) { if (!IS_ROOT(new)) {
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
dput(new); dput(new);
iput(inode);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
if (d_ancestor(new, dentry)) { if (d_ancestor(new, dentry)) {
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
dput(new); dput(new);
iput(inode);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
write_seqlock(&rename_lock); write_seqlock(&rename_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment