[PATCH 10/11] test: boot: imagemap: detach UBI when the test is done
Daniel Golle
daniel at makrotopia.org
Mon Sep 28 17:05:59 PDT 2026
The UBI test attaches UBI to the sandbox NAND and leaves it attached, so
UBI still holds a reference to the MTD device when the test ends. Running
the suite a second time crashes in mtd_partitions_used(): the test calls
mtd_probe_devices(), which rebuilds the partition list of a master whose
partitions UBI is still using, and the walk then follows a freed entry.
Detach UBI at the end of the test, and again at the start so a device
left behind by anything else is released before the partitions are
rebuilt.
Fixes: 05c1fbbfa79f ("test: boot: add imagemap unit tests")
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
test/boot/imagemap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/test/boot/imagemap.c b/test/boot/imagemap.c
index da038a33243..20a8f150a48 100644
--- a/test/boot/imagemap.c
+++ b/test/boot/imagemap.c
@@ -592,6 +592,13 @@ static int imagemap_test_ubiblock(struct unit_test_state *uts)
u64 off;
int i;
+ /*
+ * Release any device a previous run attached: UBI keeps a reference to
+ * the MTD device, and mtd_probe_devices() would then rebuild the
+ * partition list behind its back.
+ */
+ ubi_detach();
+
mtd_probe_devices();
mtd = get_mtd_device_nm("nand2");
ut_assert(!IS_ERR_OR_NULL(mtd));
@@ -638,6 +645,7 @@ static int imagemap_test_ubiblock(struct unit_test_state *uts)
imagemap_cleanup(imdev);
free(wbuf);
+ ubi_detach();
return 0;
}
--
2.55.0
More information about the openwrt-devel
mailing list