[PATCH 4/4] test: self: warn and exit if device tree parsing fails

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 9 04:52:57 PDT 2023


selftest DTs are compiled into barebox, so it's not expected that they
fail to parse. Nevertheless, error conditions shouldn't be ignored,
so warn about it and early exit.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 test/self/of_manipulation.c | 2 ++
 test/self/regulator.c       | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/test/self/of_manipulation.c b/test/self/of_manipulation.c
index 64913ac1eab8..8d645b113732 100644
--- a/test/self/of_manipulation.c
+++ b/test/self/of_manipulation.c
@@ -121,6 +121,8 @@ static void __init test_of_manipulation(void)
 
 	expected = of_unflatten_dtb(__dtb_of_manipulation_start,
 				    __dtb_of_manipulation_end - __dtb_of_manipulation_start);
+	if (WARN_ON(IS_ERR(expected)))
+		return;
 
 	assert_equal(root, expected);
 
diff --git a/test/self/regulator.c b/test/self/regulator.c
index 08073cfc9158..bcbcbe33e12f 100644
--- a/test/self/regulator.c
+++ b/test/self/regulator.c
@@ -175,6 +175,8 @@ static void test_regulator(void)
 			return;
 
 		overlay = of_unflatten_dtb(__dtbo_test_regulator_start, INT_MAX);
+		if (WARN_ON(IS_ERR(overlay)))
+			return;
 		of_overlay_apply_tree(of_get_root_node(), overlay);
 		of_probe();
 
-- 
2.39.2




More information about the barebox mailing list