From: Axel Lin <axel.lin@ingics.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Rob Landley <rob@landley.net>,
Andrew Morton <akpm@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] ramfs: Fix memory leak on ramfs_fill_super error paths
Date: Thu, 14 Nov 2013 14:59:19 +0800 [thread overview]
Message-ID: <1384412359.28992.3.camel@phoenix> (raw)
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
next reply other threads:[~2013-11-14 6:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 6:59 Axel Lin [this message]
2013-11-14 10:19 ` [PATCH] ramfs: Fix memory leak on ramfs_fill_super error paths Kirill A. Shutemov
2013-11-14 14:10 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384412359.28992.3.camel@phoenix \
--to=axel.lin@ingics.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rob@landley.net \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox