Skip to content

Commit 3b18525

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubi: fastmap: Don't produce the initial next anchor PEB when fastmap 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]>
1 parent fcf4419 commit 3b18525

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mtd/ubi/wl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,8 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)
10861086
if (!err) {
10871087
spin_lock(&ubi->wl_lock);
10881088

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

0 commit comments

Comments
 (0)