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

Sunil Mushran sunil.mushran at oracle.com
Tue May 25 13:11:37 PDT 2010


On 05/25/2010 01:19 AM, Coly Li wrote:
> 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);
>   }
>    

That's not enough. You have to free the cached_inode for each slot.
And possibly the elements in the cached inode. If we are doing this,
we might as well do it fully.





More information about the Ocfs2-tools-devel mailing list