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

Tristan tristan.ye at oracle.com
Thu Nov 5 17:40:51 PST 2009


Coly Li wrote:
> 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);
>   

I guess memory should not be placed there, it should be following instead:

else {

		ret = OCFS2_ET_INTERNAL_FAILURE;
		goto out;

}

out:
if (dp)
free(dp);
...

>  			goto out;
>  		}
>  	}
>   




More information about the Ocfs2-tools-devel mailing list