ubifs: fix double return leb in ubifs_garbage_collect

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>
This commit is contained in:
Baokun Li 2021-11-15 09:31:43 +08:00 committed by Richard Weinberger
parent 88618feecf
commit 0d76502172

View File

@ -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;