Skip to content

Commit

Permalink
ubi: fastmap: Don't produce the initial next anchor PEB when fastmap …
Browse files Browse the repository at this point in the history
…is disabled

Following process triggers a memleak caused by forgetting to release the
initial next anchor PEB (CONFIG_MTD_UBI_FASTMAP is disabled):
1. attach -> __erase_worker -> produce the initial next anchor PEB
2. detach -> ubi_fastmap_close (Do nothing, it should have released the
   initial next anchor PEB)

Don't produce the initial next anchor PEB in __erase_worker() when fastmap
is disabled.

Signed-off-by: Zhihao Cheng <[email protected]>
Suggested-by: Sascha Hauer <[email protected]>
Fixes: f9c34bb ("ubi: Fix producing anchor PEBs")
Reported-by: [email protected]
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
Zhihao Cheng authored and richardweinberger committed Aug 2, 2020
1 parent fcf4419 commit 3b18525
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,8 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)
if (!err) {
spin_lock(&ubi->wl_lock);

if (!ubi->fm_next_anchor && e->pnum < UBI_FM_MAX_START) {
if (!ubi->fm_disabled && !ubi->fm_next_anchor &&
e->pnum < UBI_FM_MAX_START) {
/* Abort anchor production, if needed it will be
* enabled again in the wear leveling started below.
*/
Expand Down

0 comments on commit 3b18525

Please sign in to comment.