summaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorBaokun Li <libaokun1@huawei.com>2021-11-15 02:31:44 +0100
committerRichard Weinberger <richard@nod.at>2021-12-23 22:30:38 +0100
commit50cb4373254433ad015dd50a061194c693b37c16 (patch)
tree8bf26d320eb8b207805b4ee414eb1786d875c016 /fs/ubifs
parentubifs: fix double return leb in ubifs_garbage_collect (diff)
downloadlinux-50cb4373254433ad015dd50a061194c693b37c16.tar.xz
linux-50cb4373254433ad015dd50a061194c693b37c16.zip
ubifs: read-only if LEB may always be taken in ubifs_garbage_collect
If ubifs_garbage_collect_leb() returns -EAGAIN and ubifs_return_leb returns error, a LEB will always has a "taken" flag. In this case, set the ubifs to read-only to prevent a worse situation. 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.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 1f74a127fe3a..3134d070fcc0 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -756,8 +756,17 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway)
* caller instead of the original '-EAGAIN'.
*/
err = ubifs_return_leb(c, lp.lnum);
- if (err)
+ if (err) {
ret = err;
+ /*
+ * An LEB may always be "taken",
+ * so setting ubifs to read-only,
+ * and then executing sync wbuf will
+ * return -EROFS and enter the "out"
+ * error branch.
+ */
+ ubifs_ro_mode(c, ret);
+ }
/* Maybe double return LEB if goto out */
lp.lnum = -1;
break;