[Ocfs2-tools-devel] [PATCH 8/8] Fix a memory leak problem in image.c
piaojun
piaojun at huawei.com
Sun Mar 29 01:25:36 PDT 2015
Hi Mark,
The whitespace errors are all fixed and there are no obvious style
problems in the patch now. Thanks for reviewing!
Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>
---
libocfs2/image.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libocfs2/image.c b/libocfs2/image.c
index 41d1a53..fe95530 100644
--- a/libocfs2/image.c
+++ b/libocfs2/image.c
@@ -66,10 +66,6 @@ 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;
--
1.8.4.3
在 2015/3/18 15:46, piaojun 写道:
> Whether OCFS2_FLAG_IMAGE_FILE is specified in 'fs_flags' or not, the
> handler will allocate memory for 'ost_bmparr'.
>
> In main(), there are two paths of memory allocation for 'ost_bmparr':
> 1. OCFS2_FLAG_IMAGE_FILE is specified: ocfs2_image_load_bitmap()->
> ocfs2_image_alloc_bitmap()->ocfs2_malloc0().
> 2. OCFS2_FLAG_IMAGE_FILE is not specified: main()->o2image_initialize()->
> ocfs2_image_alloc_bitmap()->ocfs2_malloc0().
>
> But in ocfs2_image_free_bitmap(), 'ost_bmparr' would not be freed if
> OCFS2_FLAG_IMAGE_FILE is not specified. So we should free 'ost_bmparr'
> anyway.
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> Reviewed-by: Alex Chen <alex.chen at huawei.com>
>
> ---
> libocfs2/image.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/libocfs2/image.c b/libocfs2/image.c
> index 41d1a53..fe95530 100644
> --- a/libocfs2/image.c
> +++ b/libocfs2/image.c
> @@ -66,10 +66,6 @@ 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;
>
> -- 1.8.4.3
>
>
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
>
>
More information about the Ocfs2-tools-devel
mailing list