Skip to content

Commit 1383b34

Browse files
zhaohemliu-song-6
authored andcommitted
md/bitmap: fix memory leak of temporary bitmap
Callers of get_bitmap_from_slot() are responsible to free the bitmap. Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Zhao Heming <heming.zhao@suse.com> Signed-off-by: Song Liu <songliubraving@fb.com>
1 parent cf0b9b4 commit 1383b34

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/md/md-bitmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,7 @@ int md_bitmap_load(struct mddev *mddev)
19501950
}
19511951
EXPORT_SYMBOL_GPL(md_bitmap_load);
19521952

1953+
/* caller need to free returned bitmap with md_bitmap_free() */
19531954
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
19541955
{
19551956
int rv = 0;
@@ -2013,6 +2014,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
20132014
md_bitmap_unplug(mddev->bitmap);
20142015
*low = lo;
20152016
*high = hi;
2017+
md_bitmap_free(bitmap);
20162018

20172019
return rv;
20182020
}
@@ -2616,4 +2618,3 @@ struct attribute_group md_bitmap_group = {
26162618
.name = "bitmap",
26172619
.attrs = md_bitmap_attrs,
26182620
};
2619-

drivers/md/md-cluster.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
11661166
* can't resize bitmap
11671167
*/
11681168
goto out;
1169+
md_bitmap_free(bitmap);
11691170
}
11701171

11711172
return 0;

0 commit comments

Comments
 (0)