public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ramfs: Fix memory leak on ramfs_fill_super error paths
@ 2013-11-14  6:59 Axel Lin
  2013-11-14 10:19 ` Kirill A. Shutemov
  2013-11-14 14:10 ` Al Viro
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-11-14  6:59 UTC (permalink / raw)
  To: Al Viro; +Cc: Rob Landley, Andrew Morton, Eric W. Biederman, linux-kernel

The memory leak was introduced by commit 318ceed0884
"tidy up after d_make_root() conversion".

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 fs/ramfs/inode.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 39d1465..868a41e 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -221,7 +221,7 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
 
 	err = ramfs_parse_options(data, &fsi->mount_opts);
 	if (err)
-		return err;
+		goto fail;
 
 	sb->s_maxbytes		= MAX_LFS_FILESIZE;
 	sb->s_blocksize		= PAGE_CACHE_SIZE;
@@ -232,10 +232,16 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
 
 	inode = ramfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0);
 	sb->s_root = d_make_root(inode);
-	if (!sb->s_root)
-		return -ENOMEM;
+	if (!sb->s_root) {
+		err = -ENOMEM;
+		goto fail;
+	}
 
 	return 0;
+fail:
+	kfree(fsi);
+	sb->s_fs_info = NULL;
+	return err;
 }
 
 struct dentry *ramfs_mount(struct file_system_type *fs_type,
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-14 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-14  6:59 [PATCH] ramfs: Fix memory leak on ramfs_fill_super error paths Axel Lin
2013-11-14 10:19 ` Kirill A. Shutemov
2013-11-14 14:10 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox