lkml.org 
[lkml]   [2018]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing
From
Date
Hi Boaz,

Could you have a look at this trivial patch?

Thanks,
Chengguang.

On 06/13/2018 12:05 PM, Chengguang Xu wrote:
> There are some cases can cause memory leak when parsing
> option 'osdname'.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
> fs/exofs/super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/exofs/super.c b/fs/exofs/super.c
> index 719a315..f3e17a9 100644
> --- a/fs/exofs/super.c
> +++ b/fs/exofs/super.c
> @@ -101,6 +101,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");
> @@ -867,8 +868,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;

\
 
 \ /
  Last update: 2018-06-21 04:15    [W:0.065 / U:3.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site