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

Sunil Mushran sunil.mushran at oracle.com
Mon Nov 9 15:45:28 PST 2009


Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>

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 if the internal failure happens.
>
> Signed-off-by: Coly Li <coly.li at suse.de>
> ---
>  fsck.ocfs2/dirparents.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/fsck.ocfs2/dirparents.c b/fsck.ocfs2/dirparents.c
> index 694e30c..cbf8d2c 100644
> --- a/fsck.ocfs2/dirparents.c
> +++ b/fsck.ocfs2/dirparents.c
> @@ -80,6 +80,8 @@ errcode_t o2fsck_add_dir_parent(struct rb_root *root,
>  	rb_link_node(&dp->dp_node, parent, p);
>  	rb_insert_color(&dp->dp_node, root);
>  out:
> +	if (ret && dp)
> +		free(dp);
>  	return ret;
>  }
>   




More information about the Ocfs2-tools-devel mailing list