Commit 1383b347 authored by Zhao Heming's avatar Zhao Heming Committed by Song Liu

md/bitmap: fix memory leak of temporary bitmap

Callers of get_bitmap_from_slot() are responsible to free the bitmap.
Suggested-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: default avatarZhao Heming <heming.zhao@suse.com>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
parent cf0b9b48
...@@ -1950,6 +1950,7 @@ int md_bitmap_load(struct mddev *mddev) ...@@ -1950,6 +1950,7 @@ int md_bitmap_load(struct mddev *mddev)
} }
EXPORT_SYMBOL_GPL(md_bitmap_load); EXPORT_SYMBOL_GPL(md_bitmap_load);
/* caller need to free returned bitmap with md_bitmap_free() */
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
{ {
int rv = 0; int rv = 0;
...@@ -2013,6 +2014,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, ...@@ -2013,6 +2014,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
md_bitmap_unplug(mddev->bitmap); md_bitmap_unplug(mddev->bitmap);
*low = lo; *low = lo;
*high = hi; *high = hi;
md_bitmap_free(bitmap);
return rv; return rv;
} }
...@@ -2616,4 +2618,3 @@ struct attribute_group md_bitmap_group = { ...@@ -2616,4 +2618,3 @@ struct attribute_group md_bitmap_group = {
.name = "bitmap", .name = "bitmap",
.attrs = md_bitmap_attrs, .attrs = md_bitmap_attrs,
}; };
...@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
* can't resize bitmap * can't resize bitmap
*/ */
goto out; goto out;
md_bitmap_free(bitmap);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment