[Ocfs2-tools-devel] [PATCH 3/8] Fix a memory leak problem in mount.ocfs2.c
piaojun
piaojun at huawei.com
Sun Mar 29 01:20:42 PDT 2015
Hi Mark,
The whitespace errors are all fixed and there are no obvious style
problems in the patch now. Thanks for reviewing!
Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>
---
mount.ocfs2/mount.ocfs2.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index a1c8698..0b6afa2 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -313,7 +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();
initialize_o2cb_error_table();
@@ -452,12 +452,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 +473,7 @@ bail:
free(mo.xtra_opts);
if (mo.type)
free(mo.type);
-
+ if (opts_string)
+ free(opts_string);
return ret ? 1 : 0;
}
--
1.8.4.3
在 2015/3/18 15:39, piaojun 写道:
> 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: Alex Chen <alex.chen at huawei.com>
>
> ---
> mount.ocfs2/mount.ocfs2.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
> index a1c8698..2c23ce1 100644
> --- a/mount.ocfs2/mount.ocfs2.c
> +++ b/mount.ocfs2/mount.ocfs2.c
> @@ -313,7 +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();
> initialize_o2cb_error_table();
> @@ -452,12 +452,9 @@ 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 +471,7 @@ bail:
> free(mo.xtra_opts);
> if (mo.type)
> free(mo.type);
> -
> + if (opts_string)
> + free(opts_string);
> return ret ? 1 : 0;
> }
> -- 1.8.4.3
>
>
> _______________________________________________
> 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