[Ocfs2-tools-devel] [PATCH 5/8] Fix a memory leak problem in tunefs.ocfs2
piaojun
piaojun at huawei.com
Sun Mar 29 01:23:03 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>
---
tunefs.ocfs2/libocfs2ne.c | 2 ++
tunefs.ocfs2/ocfs2ne.c | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index d940ec9..d5f1fca 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -1794,6 +1794,8 @@ static errcode_t tunefs_journal_check(ocfs2_filesys *fs)
jsb->s_feature_ro_compat;
state->ts_journal_features.opt_incompat |=
jsb->s_feature_incompat;
+ ocfs2_free_cached_inode(fs, ci);
+ ci = NULL;
}
/*
diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
index d2f06e4..47fd2b1 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)
+ ocfs2_free(&optstring);
+ if (long_options)
+ ocfs2_free(&long_options);
return err;
}
--
1.8.4.3
在 2015/3/18 15:41, piaojun 写道:
> 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
>
>
> _______________________________________________
> 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