ubi: fastmap: Only produce the initial anchor PEB when fastmap is used
authorHou Tao <houtao1@huawei.com>
Mon, 10 Feb 2020 13:26:35 +0000 (21:26 +0800)
committerRichard Weinberger <richard@nod.at>
Mon, 30 Mar 2020 21:02:36 +0000 (23:02 +0200)
Don't produce the initial anchor PEB when ubi device is read-only
or fastmap is disabled, else the resulting PEB will be unusable
to any volume.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/wl.c

index 837d690a8c60d345c9d53c878658d45236c2f1d7..5146cce5fe32115d46c3e4735777b22df991489a 100644 (file)
@@ -1875,7 +1875,8 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
                goto out_free;
 
 #ifdef CONFIG_MTD_UBI_FASTMAP
-       ubi_ensure_anchor_pebs(ubi);
+       if (!ubi->ro_mode && !ubi->fm_disabled)
+               ubi_ensure_anchor_pebs(ubi);
 #endif
        return 0;