[v2,2/2] UBI: fastmap: only produce the initial anchor PEB when fastmap is used
diff mbox series

Message ID 20200210132635.50072-2-houtao1@huawei.com
State New
Headers show
Series
  • [v2,1/2] UBI: Fastmap: free unused fastmap anchor peb during detach
Related show

Commit Message

Hou Tao Feb. 10, 2020, 1:26 p.m. UTC
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>
---
 drivers/mtd/ubi/wl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index af2fe77eb66f..87ff4e51cb8c 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1879,7 +1879,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;