[PATCH] fs: fix dentry leak in simple_fill_super()

From: Konstantin Khlebnikov
Date: Tue Nov 01 2011 - 08:12:39 EST


put dentry if inode allocation failed, d_genocide() cannot release it

Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxx>
---
fs/libfs.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index c18e9a1..a2c0029 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -510,8 +510,10 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
if (!dentry)
goto out;
inode = new_inode(s);
- if (!inode)
+ if (!inode) {
+ dput(dentry);
goto out;
+ }
inode->i_mode = S_IFREG | files->mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_fop = files->ops;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/