Skip to content

Commit

Permalink
md/bitmap: fix memory leak of temporary bitmap
Browse files Browse the repository at this point in the history
[ Upstream commit 1383b34 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
zhaohem authored and gregkh committed Oct 29, 2020
1 parent 44a58dd commit 4c4b1a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/md/md-bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,7 @@ int md_bitmap_load(struct mddev *mddev)
}
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)
{
int rv = 0;
Expand Down Expand Up @@ -2012,6 +2013,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;
}
Expand Down Expand Up @@ -2615,4 +2617,3 @@ struct attribute_group md_bitmap_group = {
.name = "bitmap",
.attrs = md_bitmap_attrs,
};

1 change: 1 addition & 0 deletions drivers/md/md-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c4b1a2

Please sign in to comment.