[Ocfs2-tools-devel] [PATCH] fsck.ocfs2: fix a minor memleak

Coly Li coly.li at suse.de
Thu Nov 5 08:40:46 PST 2009


In o2fsck_add_dir_parent(), if a identical key exists already, the code returns OCFS2_ET_INTERNAL_FAILURE without
freeing memory of dp. It's a non-critical memleak, since fsck.ocfs2 will abort against this error.

This patch frees the memory when the internal failure happens.

Signed-off-by: Coly Li <coly.li at suse.de>
---
 fsck.ocfs2/dirparents.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fsck.ocfs2/dirparents.c b/fsck.ocfs2/dirparents.c
index 694e30c..08a1f70 100644
--- a/fsck.ocfs2/dirparents.c
+++ b/fsck.ocfs2/dirparents.c
@@ -73,6 +73,7 @@ errcode_t o2fsck_add_dir_parent(struct rb_root *root,
 			p = &(*p)->rb_right;
 		else {
 			ret = OCFS2_ET_INTERNAL_FAILURE;
+			free(dp);
 			goto out;
 		}
 	}
-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list