[Ocfs2-tools-devel] [PATCH] o2image: fix a memory leak problem in ocfs2_image_free_bitmap()

Joseph Qi joseph.qi at huawei.com
Sat Jul 30 01:07:00 PDT 2016


Hi Jun,
One patch for one thing, so I don't think the code cleanup for ocfs2_free
here is a good idea.

Thanks,
Joseph

On 2016/7/30 15:18, piaojun wrote:
> whether OCFS2_FLAG_IMAGE_FILE is set or not, we will allocate image
> bitmaps by ocfs2_image_alloc_bitmap(), so we should free them in
> ocfs2_image_free_bitmap() anyway.
> 
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> ---
>  libocfs2/image.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/libocfs2/image.c b/libocfs2/image.c
> index 41d1a53..e94e098 100644
> --- a/libocfs2/image.c
> +++ b/libocfs2/image.c
> @@ -66,19 +66,13 @@ errcode_t ocfs2_image_free_bitmap(ocfs2_filesys *ofs)
>  	struct ocfs2_image_state *ost = ofs->ost;
>  	int i;
>  
> -	/* image bitmaps are allocated only for ocfs2 image image files */
> -	if (!(ofs->fs_flags & OCFS2_FLAG_IMAGE_FILE))
> -		return 0;
> -
>  	if (!ost->ost_bmparr)
>  		return 0;
>  
> -	for (i=0; i<ost->ost_bmpblks; i++)
> -		if (ost->ost_bmparr[i].arr_self)
> -			ocfs2_free(&ost->ost_bmparr[i].arr_self);
> +	for (i = 0; i < ost->ost_bmpblks; i++)
> +		ocfs2_free(&ost->ost_bmparr[i].arr_self);
>  
> -	if (ost->ost_bmparr)
> -		ocfs2_free(&ost->ost_bmparr);
> +	ocfs2_free(&ost->ost_bmparr);
>  	return 0;
>  }
>  
> 





More information about the Ocfs2-tools-devel mailing list