[Ocfs2-tools-devel] [PATCH 5/8] Fix a memory leak problem in tunefs.ocfs2
piaojun
piaojun at huawei.com
Wed Mar 18 00:41:39 PDT 2015
1. In tunefs_journal_check(), new memory will be allocated for 'ci' in each
time of loop, so 'ci' should be freed at the end of each time of loop.
2. In parse_options(), 'optstring' and 'long_options' should be freed after
use.
Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>
---
tunefs.ocfs2/libocfs2ne.c | 4 ++++
tunefs.ocfs2/ocfs2ne.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index d940ec9..ed8a3c1 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -1794,6 +1794,10 @@ static errcode_t tunefs_journal_check(ocfs2_filesys *fs)
jsb->s_feature_ro_compat;
state->ts_journal_features.opt_incompat |=
jsb->s_feature_incompat;
+ if (ci) {
+ ocfs2_free_cached_inode(fs, ci);
+ ci = NULL;
+ }
}
/*
diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
index d2f06e4..0e7be86 100644
--- a/tunefs.ocfs2/ocfs2ne.c
+++ b/tunefs.ocfs2/ocfs2ne.c
@@ -1002,6 +1002,10 @@ static errcode_t parse_options(int argc, char *argv[], char **device)
}
out:
+ if(optstring)
+ free(optstring);
+ if (long_options)
+ free(long_options);
return err;
}
-- 1.8.4.3
More information about the Ocfs2-tools-devel
mailing list