fix memory leak for bitmap
PATCH 1/1 fix memory leak for bitmap
current code doesn't free temporary bitmap memory.
--- drivers/md/md-bitmap.c | 1 + drivers/md/md-cluster.c | 1 + 2 files changed, 2 insertions(+)
drivers/md/md-bitmap.c +1 -0
@@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,md_bitmap_unplug (mddev->bitmap); *low = lo; *high = hi; +md_bitmap_free (bitmap);return rv; }
drivers/md/md-cluster.c +1 -0
@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz* can't resize bitmap */ goto out; +md_bitmap_free (bitmap); }return 0 ;
Signature · 1 line
1.8.3.1
Quoted 25 lines · Zhao Heming
current code doesn't free temporary bitmap memory.
Signed-off-by Zhao Heming <[email protected]>--- drivers/md/md-bitmap.c | 1 + drivers/md/md-cluster.c | 1 + 2 files changed, 2 insertions(+)drivers/md/md-bitmap.c +1
-0@@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,md_bitmap_unplug (mddev->bitmap); *low = lo; *high = hi; +md_bitmap_free (bitmap);return rv; }drivers/md/md-cluster.c +0
-0
drivers/md/md-cluster.c static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz · line 1172
Quoted 7 lines
drivers/md/md-cluster.c +1
-0@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz* can't resize bitmap */ goto out; +md_bitmap_free (bitmap); }return 0 ;
I'd prefer add a comment for get_bitmap_from_slot to mention it's caller need to free bitmap.
Thanks,
Guoqing
Song Liu
maintainerQuoted 35 lines · Guoqing Jiang
Quoted 31 lines · Zhao Heming
current code doesn't free temporary bitmap memory.
Signed-off-by Zhao Heming <[email protected]>--- drivers/md/md-bitmap.c | 1 + drivers/md/md-cluster.c | 1 + 2 files changed, 2 insertions(+)drivers/md/md-bitmap.c +1
-0@@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,md_bitmap_unplug (mddev->bitmap); *low = lo; *high = hi; +md_bitmap_free (bitmap);return rv; }drivers/md/md-cluster.c +1
-0@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz* can't resize bitmap */ goto out; +md_bitmap_free (bitmap); }
Quoted 5 lines
drivers/md/md-cluster.c static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz · line 1172
Quoted 1 line
drivers/md/md-cluster.c +0
-0return 0 ;I'd prefer add a comment for
get_bitmap_from_slotto mention it's caller need to
free bitmap.
I added comment to the patch with Guoqing's "Suggested-by" tag, and applied it to md-next. I also made some changes to the commit log of all 3 patches from Heming.
Herming, for future patches, please prefix the subject with "md:" or "md/bitmap".
Thanks,
Song
Hello Song & Guoqing,
Thank you for your review.
I will take your advises & take more attention on later.
Quoted 53 lines · Song Liu
Quoted 35 lines · Guoqing Jiang
Quoted 31 lines · Zhao Heming
current code doesn't free temporary bitmap memory.
Signed-off-by Zhao Heming <[email protected]>--- drivers/md/md-bitmap.c | 1 + drivers/md/md-cluster.c | 1 + 2 files changed, 2 insertions(+)drivers/md/md-bitmap.c +1
-0@@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,md_bitmap_unplug (mddev->bitmap); *low = lo; *high = hi; +md_bitmap_free (bitmap);return rv; }drivers/md/md-cluster.c +1
-0@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz* can't resize bitmap */ goto out; +md_bitmap_free (bitmap); }Quoted 5 lines
drivers/md/md-cluster.c static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz · line 1172
Quoted 1 line
drivers/md/md-cluster.c +0
-0return 0 ;I'd prefer add a comment for
get_bitmap_from_slotto mention it's caller need to
free bitmap.I added comment to the patch with Guoqing's "Suggested-by" tag, and applied it to md-next. I also made some changes to the commit log of all 3 patches from Heming.
Herming, for future patches, please prefix the subject with "md:" or "md/bitmap".
Thanks,
Song