Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Zhao Heming and committed by
Song Liu
1383b347 cf0b9b48

+3 -1
+2 -1
drivers/md/md-bitmap.c
··· 1950 1950 } 1951 1951 EXPORT_SYMBOL_GPL(md_bitmap_load); 1952 1952 1953 + /* caller need to free returned bitmap with md_bitmap_free() */ 1953 1954 struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) 1954 1955 { 1955 1956 int rv = 0; ··· 2014 2013 md_bitmap_unplug(mddev->bitmap); 2015 2014 *low = lo; 2016 2015 *high = hi; 2016 + md_bitmap_free(bitmap); 2017 2017 2018 2018 return rv; 2019 2019 } ··· 2618 2616 .name = "bitmap", 2619 2617 .attrs = md_bitmap_attrs, 2620 2618 }; 2621 -
+1
drivers/md/md-cluster.c
··· 1166 1166 * can't resize bitmap 1167 1167 */ 1168 1168 goto out; 1169 + md_bitmap_free(bitmap); 1169 1170 } 1170 1171 1171 1172 return 0;