Skip to content

Commit

Permalink
UBI: Fastmap: Fix memory leaks while closing the WL sub-system
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Richard Weinberger committed Mar 26, 2015
1 parent c4ca6be commit 74cdaf2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,13 +2064,31 @@ 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
*/
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);
Expand Down

0 comments on commit 74cdaf2

Please sign in to comment.