[PATCH v2 30/62] UBI: Fastmap: Switch to ro mode if invalidate_fastmap() fails

Teresa Remmet t.remmet at phytec.de
Fri May 27 00:44:23 PDT 2016


From: Richard Weinberger <richard at nod.at>

We have to switch to ro mode to guarantee that upon next UBI attach
all data is consistent.

Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Teresa Remmet <t.remmet at phytec.de>
---
 drivers/mtd/ubi/fastmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index f683d42..d94e1d9 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1458,8 +1458,10 @@ err:
 	ret = 0;
 	if (old_fm) {
 		ret = invalidate_fastmap(ubi, old_fm);
-		if (ret < 0)
+		if (ret < 0) {
 			ubi_err(ubi, "Unable to invalidiate current fastmap!");
+			ubi_ro_mode(ubi);
+		}
 		else if (ret)
 			ret = 0;
 	}
-- 
1.9.1




More information about the barebox mailing list