aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2014-09-19 11:37:56 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-09-24 08:36:16 -0400
commitb91671bb23a79c32a23b0ad5d6e6ad292bb21bdf (patch)
treebb544e7b059228789411b4a601ad6e2157a38e08
parent7fbbd05799976c0611dcb229649260504b2bdef5 (diff)
UBI: Fix livelock in produce_free_peb()
The while loop in produce_free_peb() assumes that each work will produce a free PEB. This is not true. If ubi->works_count is 1 and the only scheduled work is the wear_leveling_worker() produce_free_peb() can loop forever in case nobody schedules an erase work. Fix this issue by checking in the while loop whether work is scheduled. 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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 20f491713145..32b3c1486a05 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -272,7 +272,7 @@ static int produce_free_peb(struct ubi_device *ubi)
272{ 272{
273 int err; 273 int err;
274 274
275 while (!ubi->free.rb_node) { 275 while (!ubi->free.rb_node && ubi->works_count) {
276 spin_unlock(&ubi->wl_lock); 276 spin_unlock(&ubi->wl_lock);
277 277
278 dbg_wl("do one work synchronously"); 278 dbg_wl("do one work synchronously");