diff options
author | Richard Weinberger <richard@nod.at> | 2013-08-19 08:48:12 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-01-07 11:03:24 +0100 |
commit | 92924e7ae171609a748df38ce91763cc3e05bfa7 (patch) | |
tree | d0cff937bb404052462bf0a7924e8cc17975bbf3 /drivers | |
parent | 0cff096e583cb39f0a421d2740848f9d922362f2 (diff) | |
download | barebox-92924e7ae171609a748df38ce91763cc3e05bfa7.tar.gz barebox-92924e7ae171609a748df38ce91763cc3e05bfa7.tar.xz |
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 ed4b7021c
(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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/ubi/wl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index d0d3c97ecf..5a79e98c1a 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1020,6 +1020,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); |