From: Richard Weinberger Date: Fri, 19 Sep 2014 15:37:56 +0000 (+0200) Subject: UBI: Fix livelock in produce_free_peb() X-Git-Tag: firefly_0821_release~176^2~3039^2~6 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b91671bb23a79c32a23b0ad5d6e6ad292bb21bdf;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Artem Bityutskiy --- 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) { int err; - while (!ubi->free.rb_node) { + while (!ubi->free.rb_node && ubi->works_count) { spin_unlock(&ubi->wl_lock); dbg_wl("do one work synchronously");