Skip to content

Commit 74cdaf2

Browse files
UBI: Fastmap: Fix memory leaks while closing the WL sub-system
Add a ubi_fastmap_close() to free all resources used by fastmap at WL shutdown. Signed-off-by: Richard Weinberger <[email protected]> Tested-by: Guido Martínez <[email protected]> Reviewed-by: Guido Martínez <[email protected]>
1 parent c4ca6be commit 74cdaf2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/mtd/ubi/wl.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,13 +2064,31 @@ static void protection_queue_destroy(struct ubi_device *ubi)
20642064
}
20652065
}
20662066

2067+
static void ubi_fastmap_close(struct ubi_device *ubi)
2068+
{
2069+
#ifdef CONFIG_MTD_UBI_FASTMAP
2070+
int i;
2071+
2072+
flush_work(&ubi->fm_work);
2073+
return_unused_pool_pebs(ubi, &ubi->fm_pool);
2074+
return_unused_pool_pebs(ubi, &ubi->fm_wl_pool);
2075+
2076+
if (ubi->fm) {
2077+
for (i = 0; i < ubi->fm->used_blocks; i++)
2078+
kfree(ubi->fm->e[i]);
2079+
}
2080+
kfree(ubi->fm);
2081+
#endif
2082+
}
2083+
20672084
/**
20682085
* ubi_wl_close - close the wear-leveling sub-system.
20692086
* @ubi: UBI device description object
20702087
*/
20712088
void ubi_wl_close(struct ubi_device *ubi)
20722089
{
20732090
dbg_wl("close the WL sub-system");
2091+
ubi_fastmap_close(ubi);
20742092
shutdown_work(ubi);
20752093
protection_queue_destroy(ubi);
20762094
tree_destroy(&ubi->used);

0 commit comments

Comments
 (0)