[Ocfs2-tools-devel] [PATCH] ocfs2-tools: Fix memory leak problems in mount.ocfs2
Joseph Qi
joseph.qi at huawei.com
Fri Apr 22 23:32:46 PDT 2016
On 2016/4/23 9:28, piaojun wrote:
> In main(), the memory allocated in fix_opts_string() should be freed
> after use.
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Joseph Qi <joseph.qi at huawei.com>
> ---
> mount.ocfs2/mount.ocfs2.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
> index a1c8698..d0cfcb7 100644
> --- a/mount.ocfs2/mount.ocfs2.c
> +++ b/mount.ocfs2/mount.ocfs2.c
> @@ -313,6 +313,7 @@ int main(int argc, char **argv)
> int group_join = 0;
> struct stat statbuf;
> const char *spec;
> + char *opts_string = NULL;
>
> initialize_ocfs_error_table();
> initialize_o2dl_error_table();
> @@ -453,11 +454,11 @@ int main(int argc, char **argv)
>
> change_local_hb_io_priority(fs, mo.dev);
>
> - update_mtab_entry(mo.dev, mo.dir, OCFS2_FS_NAME,
> - fix_opts_string(((mo.flags & ~MS_NOMTAB) |
> - (clustered ? MS_NETDEV : 0)),
> - mo.xtra_opts, NULL),
> - mo.flags, 0, 0);
> + opts_string = fix_opts_string(((mo.flags & ~MS_NOMTAB) |
> + (clustered ? MS_NETDEV : 0)),
> + mo.xtra_opts, NULL);
> + update_mtab_entry(mo.dev, mo.dir, OCFS2_FS_NAME, opts_string,
> + mo.flags, 0, 0);
>
> block_signals (SIG_UNBLOCK);
>
> @@ -474,6 +475,8 @@ bail:
> free(mo.xtra_opts);
> if (mo.type)
> free(mo.type);
> + if (opts_string)
> + free(opts_string);
>
> return ret ? 1 : 0;
> }
>
More information about the Ocfs2-tools-devel
mailing list