aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-08-19 02:48:12 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-08-19 11:15:11 -0400
commit5ef4414f4bc26a19cfd5cd11aee9697a863e4d51 (patch)
treeacc970ed3980932f92e0b7a2440ba8335bae8ccd
parentb36f4be3de1b123d8601de062e7dbfc904f305fb (diff)
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>
-rw-r--r--drivers/mtd/ubi/wl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 5df49d3cb5c7..c95bfb183c62 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1069,6 +1069,9 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
1069 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) { 1069 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) {
1070 dbg_wl("no WL needed: min used EC %d, max free EC %d", 1070 dbg_wl("no WL needed: min used EC %d, max free EC %d",
1071 e1->ec, e2->ec); 1071 e1->ec, e2->ec);
1072
1073 /* Give the unused PEB back */
1074 wl_tree_add(e2, &ubi->free);
1072 goto out_cancel; 1075 goto out_cancel;
1073 } 1076 }
1074 self_check_in_wl_tree(ubi, e1, &ubi->used); 1077 self_check_in_wl_tree(ubi, e1, &ubi->used);