[Ocfs2-tools-devel] [PATCH] ocfs2-tools: Fix memory leak problems in mount.ocfs2
Gang He
ghe at suse.com
Sun Apr 24 22:44:14 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>
Reviewed-by: Gang He <ghe at suse.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;
>> }
>>
>
>
>
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
More information about the Ocfs2-tools-devel
mailing list