Skip to content

Commit 5ef4414

Browse files
richardweinbergerdedekind
authored andcommitted
UBI: Fix PEB leak in wear_leveling_worker()
get_peb_for_wl() removes the PEB from the free list. If the WL subsystem detects that no wear leveling is needed it cancels the operation and drops the gained PEB. In this case we have to put the PEB back into the free list. This issue was introduced with commit ed4b702 (UBI: remove PEB from free tree in get_peb_for_wl()). Cc: <stable@vger.kernel.org> # 3.7.x Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent b36f4be commit 5ef4414

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎drivers/mtd/ubi/wl.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,9 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
10691069
if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) {
10701070
dbg_wl("no WL needed: min used EC %d, max free EC %d",
10711071
e1->ec, e2->ec);
1072+
1073+
/* Give the unused PEB back */
1074+
wl_tree_add(e2, &ubi->free);
10721075
goto out_cancel;
10731076
}
10741077
self_check_in_wl_tree(ubi, e1, &ubi->used);

0 commit comments

Comments
 (0)