diff options
author | Richard Weinberger <richard@nod.at> | 2014-10-06 14:42:01 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-03-26 22:45:48 +0100 |
commit | 74cdaf24004aea8de350f58979548b3eddc11e9a (patch) | |
tree | db3caf95458bbd79caf909f1576a56867ed0e13c /drivers/mtd | |
parent | c4ca6be9d67eaf5a53054903530c8f422b4b88bd (diff) |
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 <richard@nod.at>
Tested-by: Guido MartÃnez <guido@vanguardiasur.com.ar>
Reviewed-by: Guido MartÃnez <guido@vanguardiasur.com.ar>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/wl.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 34a8ec44cc59..11e0d7523d14 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -2064,6 +2064,23 @@ static void protection_queue_destroy(struct ubi_device *ubi) } } +static void ubi_fastmap_close(struct ubi_device *ubi) +{ +#ifdef CONFIG_MTD_UBI_FASTMAP + int i; + + flush_work(&ubi->fm_work); + return_unused_pool_pebs(ubi, &ubi->fm_pool); + return_unused_pool_pebs(ubi, &ubi->fm_wl_pool); + + if (ubi->fm) { + for (i = 0; i < ubi->fm->used_blocks; i++) + kfree(ubi->fm->e[i]); + } + kfree(ubi->fm); +#endif +} + /** * ubi_wl_close - close the wear-leveling sub-system. * @ubi: UBI device description object @@ -2071,6 +2088,7 @@ static void protection_queue_destroy(struct ubi_device *ubi) void ubi_wl_close(struct ubi_device *ubi) { dbg_wl("close the WL sub-system"); + ubi_fastmap_close(ubi); shutdown_work(ubi); protection_queue_destroy(ubi); tree_destroy(&ubi->used); |