[Ocfs2-tools-devel] [PATCH 1/8] Fix a memory leak problem in journal.c

piaojun piaojun at huawei.com
Sun Mar 29 01:18:41 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>

---
 fsck.ocfs2/journal.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fsck.ocfs2/journal.c b/fsck.ocfs2/journal.c
index ff47633..cec867a 100644
--- a/fsck.ocfs2/journal.c
+++ b/fsck.ocfs2/journal.c
@@ -925,6 +925,10 @@ static errcode_t check_journal_walk(o2fsck_state *ost,
 		ret = func(ost, ci, jc);
 		if (ret)
 			break;
+		if (ci) {
+			ocfs2_free_cached_inode(fs, ci);
+			ci = NULL;
+		}
 	}

 	if (ci)
-- 
1.8.4.3

在 2015/3/18 15:37, piaojun 写道:
> In check_journal_walk(), 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.
> 
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> Reviewed-by: Alex Chen <alex.chen at huawei.com>
> 
> ---
>  fsck.ocfs2/journal.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fsck.ocfs2/journal.c b/fsck.ocfs2/journal.c
> index ff47633..31557b7 100644
> --- a/fsck.ocfs2/journal.c
> +++ b/fsck.ocfs2/journal.c
> @@ -925,6 +925,10 @@ static errcode_t check_journal_walk(o2fsck_state *ost,
>  		ret = func(ost, ci, jc);
>  		if (ret)
>  			break;
> +		if (ci) {
> +			ocfs2_free_cached_inode(fs, ci);
> +			ci = NULL;
> +		}								
>  	}
> 
>  	if (ci)
> -- 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