[U-Boot] [PATCH] ubi: Fix filesystem corruption on detach when fastmap enabled
Martin Townsend
mtownsend1973 at gmail.com
Fri Jan 12 19:03:11 UTC 2018
>From d35b7ea298fbd6c9d08b1b7132d43b9289d2b914 Mon Sep 17 00:00:00 2001
From: Martin Townsend <mtownsend1973 at gmail.com>
Date: Fri, 12 Jan 2018 18:59:23 +0000
Subject: [PATCH] ubi: Fix filesystem corruption on detach when fastmap enabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When detaching using "ubi detach" it calls ubi_detach_mtd_dev which
calls ubi_update_fastmap twice when fastmap is enabled. The second
invocation was corrupting the ubifs as it was called after uif_close.
Moved all calls to ubi_wl_close before uif_close.
Signed-off-by: Martin Townsend <mtownsend1973 at gmail.com>
---
drivers/mtd/ubi/build.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index baf4e2d..795ea34 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1082,9 +1082,9 @@ out_debugfs:
out_uif:
get_device(&ubi->dev);
ubi_assert(ref);
+ ubi_wl_close(ubi);
uif_close(ubi);
out_detach:
- ubi_wl_close(ubi);
ubi_free_internal_volumes(ubi);
vfree(ubi->vtbl);
out_free:
@@ -1161,9 +1161,9 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
get_device(&ubi->dev);
ubi_debugfs_exit_dev(ubi);
+ ubi_wl_close(ubi);
uif_close(ubi);
- ubi_wl_close(ubi);
ubi_free_internal_volumes(ubi);
vfree(ubi->vtbl);
put_mtd_device(ubi->mtd);
--
2.7.4
More information about the U-Boot
mailing list