[Ocfs2-tools-devel] [PATCH] libocfs2: memory leak fix in ocfs2_open()

Coly Li coly.li at suse.de
Tue May 25 01:19:09 PDT 2010


ocfs2_open() allocates memory for fs->fs_eb_allocs and
fs->fs_inode_allocs, but ocfs2_close() does not free these memory
blocks. I happens to catch the error by valgrind test for check_metaecc.
This patch fixes the above memory leak.

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

diff --git a/libocfs2/freefs.c b/libocfs2/freefs.c
index ab8a8ea..5a92cd6 100644
--- a/libocfs2/freefs.c
+++ b/libocfs2/freefs.c
@@ -46,6 +46,10 @@ void ocfs2_freefs(ocfs2_filesys *fs)
 		ocfs2_free(&fs->fs_devname);
 	if (fs->fs_io)
 		io_close(fs->fs_io);
+	if (fs->fs_eb_allocs)
+		ocfs2_free(&fs->fs_eb_allocs);
+	if (fs->fs_inode_allocs)
+		ocfs2_free(&fs->fs_inode_allocs);
 
 	ocfs2_free(&fs);
 }
-- 
1.7.0.3




More information about the Ocfs2-tools-devel mailing list