lkml.org 
[lkml]   [2013]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] ramfs: Fix memory leak on ramfs_fill_super error paths
From
Date
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




\
 
 \ /
  Last update: 2013-11-14 08:41    [W:0.040 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site