[U-Boot] [PATCH] ubi: reset mtd_devs when ubi part fail

Heiko Schocher hs at denx.de
Tue Jan 20 09:05:23 CET 2015


if "ubi part" fails, reset also mtd_devs to 0, as
further "ubi part" would use wrong mtd_devs.

Signed-off-by: Heiko Schocher <hs at denx.de>

---
This issue was posted from Andrew here:

http://patchwork.ozlabs.org/patch/410507/
Patchwork [U-Boot] ubi: reset relevant globals in ubi_exit()

Could this produce with current mainline also now, and
fixed it in ubi_init() in the error path too.

Andrew: could you test this patch?
(Should I add your Signed-off-by ?)

 drivers/mtd/ubi/build.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 584cf5f..290d524 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1358,6 +1358,10 @@ out_version:
 out_class:
 	class_destroy(ubi_class);
 out:
+#ifdef __UBOOT__
+	/* Reset any globals that the driver depends on being zeroed */
+	mtd_devs = 0;
+#endif
 	ubi_err("cannot initialize UBI, error %d", err);
 	return err;
 }
@@ -1384,6 +1388,10 @@ void ubi_exit(void)
 	misc_deregister(&ubi_ctrl_cdev);
 	class_remove_file(ubi_class, &ubi_version);
 	class_destroy(ubi_class);
+#ifdef __UBOOT__
+	/* Reset any globals that the driver depends on being zeroed */
+	mtd_devs = 0;
+#endif
 }
 module_exit(ubi_exit);
 
-- 
2.1.0



More information about the U-Boot mailing list