[Ocfs2-tools-devel] [PATCH] tunefs.ocfs2: fix memory leak problems in tunefs_journal_check() and parse_options()

Joseph Qi joseph.qi at huawei.com
Wed Aug 17 20:38:29 PDT 2016


On 2016/8/18 11:12, piaojun wrote:
> Two memory leak problems were found in tunefs.ocfs2 described as bellow:
> 1. Free 'ci' in each cycle of the loop in tunefs_journal_check();
> 2. Free 'long_options' and 'optstring' at the end of parse_options().
> 
> Signed-off-by: Jun Piao <piaojun at huawei.com>
Thanks,Jun。
Reviewed-by:Joseph Qi <joseph.qi at huawei.com>

> ---
>  tunefs.ocfs2/libocfs2ne.c | 1 +
>  tunefs.ocfs2/ocfs2ne.c    | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
> index 1f4796b..20bee9f 100644
> --- a/tunefs.ocfs2/libocfs2ne.c
> +++ b/tunefs.ocfs2/libocfs2ne.c
> @@ -1794,6 +1794,7 @@ static errcode_t tunefs_journal_check(ocfs2_filesys *fs)
>  			jsb->s_feature_ro_compat;
>  		state->ts_journal_features.opt_incompat |=
>  			jsb->s_feature_incompat;
> +		ocfs2_free_cached_inode(fs, ci);
>  	}
>  
>  	/*
> diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
> index d2f06e4..368d316 100644
> --- a/tunefs.ocfs2/ocfs2ne.c
> +++ b/tunefs.ocfs2/ocfs2ne.c
> @@ -1002,6 +1002,8 @@ static errcode_t parse_options(int argc, char *argv[], char **device)
>  	}
>  
>  out:
> +	ocfs2_free(&optstring);
> +	ocfs2_free(&long_options);
>  	return err;
>  }
>  
> 





More information about the Ocfs2-tools-devel mailing list