Skip to content

Commit

Permalink
fs/exofs: fix potential memory leak in mount option parsing
Browse files Browse the repository at this point in the history
[ Upstream commit 515f1867addaba49c1c6ac73abfaffbc192c1db4 ]

There are some cases can cause memory leak when parsing
option 'osdname'.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Chengguang Xu authored and TheStreak969 committed Jan 20, 2019
1 parent a0a62e5 commit a4f4793
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/exofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
token = match_token(p, tokens, args);
switch (token) {
case Opt_name:
kfree(opts->dev_name);
opts->dev_name = match_strdup(&args[0]);
if (unlikely(!opts->dev_name)) {
EXOFS_ERR("Error allocating dev_name");
Expand Down Expand Up @@ -868,8 +869,10 @@ static struct dentry *exofs_mount(struct file_system_type *type,
int ret;

ret = parse_options(data, &opts);
if (ret)
if (ret) {
kfree(opts.dev_name);
return ERR_PTR(ret);
}

if (!opts.dev_name)
opts.dev_name = dev_name;
Expand Down

0 comments on commit a4f4793

Please sign in to comment.