aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2014-10-06 08:42:01 -0400
committerRichard Weinberger <richard@nod.at>2015-03-26 17:45:48 -0400
commit74cdaf24004aea8de350f58979548b3eddc11e9a (patch)
treedb3caf95458bbd79caf909f1576a56867ed0e13c
parentc4ca6be9d67eaf5a53054903530c8f422b4b88bd (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>
-rw-r--r--drivers/mtd/ubi/wl.c18
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)
2064 } 2064 }
2065} 2065}
2066 2066
2067static 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
2067/** 2084/**
2068 * ubi_wl_close - close the wear-leveling sub-system. 2085 * ubi_wl_close - close the wear-leveling sub-system.
2069 * @ubi: UBI device description object 2086 * @ubi: UBI device description object
@@ -2071,6 +2088,7 @@ static void protection_queue_destroy(struct ubi_device *ubi)
2071void ubi_wl_close(struct ubi_device *ubi) 2088void ubi_wl_close(struct ubi_device *ubi)
2072{ 2089{
2073 dbg_wl("close the WL sub-system"); 2090 dbg_wl("close the WL sub-system");
2091 ubi_fastmap_close(ubi);
2074 shutdown_work(ubi); 2092 shutdown_work(ubi);
2075 protection_queue_destroy(ubi); 2093 protection_queue_destroy(ubi);
2076 tree_destroy(&ubi->used); 2094 tree_destroy(&ubi->used);