[Ocfs2-tools-devel] [PATCH 3/8 V2] Fix a memory leak problem in mount.ocfs2.c
piaojun
piaojun at huawei.com
Sun Mar 29 18:48:38 PDT 2015
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 | 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
More information about the Ocfs2-tools-devel
mailing list