mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] UBI: Fix PEB leak in wear_leveling_worker()
@ 2013-08-19  6:48 Richard Weinberger
  2013-08-19 15:21 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2013-08-19  6:48 UTC (permalink / raw)
  To: dedekind1; +Cc: dwmw2, linux-mtd, linux-kernel, Richard Weinberger, stable

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>
---
 drivers/mtd/ubi/wl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 5df49d3..c95bfb1 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,
 		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);
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] UBI: Fix PEB leak in wear_leveling_worker()
  2013-08-19  6:48 [PATCH] UBI: Fix PEB leak in wear_leveling_worker() Richard Weinberger
@ 2013-08-19 15:21 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2013-08-19 15:21 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: dwmw2, linux-mtd, linux-kernel, stable

On Mon, 2013-08-19 at 08:48 +0200, Richard Weinberger wrote:
> 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>

Pushed to linux-ubi.git, thanks.

And special thanks for taking care about Ccing -stable.

-- 
Best Regards,
Artem Bityutskiy


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-19 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-19  6:48 [PATCH] UBI: Fix PEB leak in wear_leveling_worker() Richard Weinberger
2013-08-19 15:21 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome