Skip to content

Commit

Permalink
ubifs: fix double return leb in ubifs_garbage_collect
Browse files Browse the repository at this point in the history
If ubifs_garbage_collect_leb() returns -EAGAIN and enters the "out"
branch, ubifs_return_leb will execute twice on the same lnum. This
can cause data loss in concurrency situations.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Baokun Li authored and Richard Weinberger committed Dec 23, 2021
1 parent 88618fe commit 0d76502
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/ubifs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway)
err = ubifs_return_leb(c, lp.lnum);
if (err)
ret = err;
/* Maybe double return LEB if goto out */
lp.lnum = -1;
break;
}
goto out;
Expand Down

0 comments on commit 0d76502

Please sign in to comment.