Skip to content

Commit

Permalink
UBI: Fix PEB leak in wear_leveling_worker()
Browse files Browse the repository at this point in the history
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: <[email protected]> # 3.7.x
Signed-off-by: Richard Weinberger <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
  • Loading branch information
richardweinberger authored and jhofstee committed Mar 26, 2014
1 parent 514a7cc commit 6498fb1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,9 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) {
dbg_wl("no WL needed: min used EC %d, max free EC %d",
e1->ec, e2->ec);

/* Give the unused PEB back */
wl_tree_add(e2, &ubi->free);
goto out_cancel;
}
self_check_in_wl_tree(ubi, e1, &ubi->used);
Expand Down

0 comments on commit 6498fb1

Please sign in to comment.