Skip to content

Commit

Permalink
UBI: Fix livelock in produce_free_peb()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Richard Weinberger authored and Artem Bityutskiy committed Sep 24, 2014
1 parent 7fbbd05 commit b91671b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit b91671b

Please sign in to comment.