summaryrefslogtreecommitdiff
path: root/fs/ubifs
diff options
context:
space:
mode:
authorBaokun Li <libaokun1@huawei.com>2021-11-15 09:31:43 +0800
committerRichard Weinberger <richard@nod.at>2021-12-23 22:28:23 +0100
commit0d76502172d83e1e09aedbdced3d8be0ef1abcb5 (patch)
treee02cb685339c7435445626520ecd116925833bfa /fs/ubifs
parent88618feecf44e774e03cf49872567398b0177d25 (diff)
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>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/gc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 05e1eeae8457..1f74a127fe3a 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -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;