[Devel] [PATCH rh7 14/14] fix inode leaks on d_splice_alias() failure exits
Andrey Ryabinin
aryabinin at virtuozzo.com
Mon Jun 10 18:14:00 MSK 2019
From: Al Viro <viro at zeniv.linux.org.uk>
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 at vger.kernel.org
Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>
(cherry picked from commit 51486b900ee92856b977eacfc5bfbe6565028070)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
fs/dcache.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/dcache.c b/fs/dcache.c
index a1be93d7101d..7c39b6a0c190 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2830,11 +2830,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);
--
2.21.0
More information about the Devel
mailing list