Skip to contentSkip to conversation

fs: fix dentry leak in simple_fill_super()

PATCH In review Konstantin Khlebnikov 2 participants 2 messages Nov 1, 2011 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fix dentry leak in simple_fill_super()

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

---
 fs/libfs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/libfs.c +3 -1
index c18e9a1..a2c0029 100644
@@ -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;
reviewer
#1 lore raw
Quoted 1 line · Konstantin Khlebnikov

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

Al is currently ill and Christoph Hellwig is taking care of fixes for
now. Added him to CC...

Honza

Quoted 27 lines
---
 fs/libfs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/libfs.c +3 -2
index c18e9a1..a2c0029 100644
@@ -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-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR