summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-06-01 19:22:31 +0300
committerTom Rini <trini@konsulko.com>2023-07-14 19:54:50 +0300
commita6c4f188948eaf957da8595dd76d947b8bad005a (patch)
treeab76ae4e898e1f4ddd1cf753ce950b442d80245c
parent11c341b118a236423a294a7d62f71bf33e20aea3 (diff)
downloadu-boot-a6c4f188948eaf957da8595dd76d947b8bad005a.tar.xz
dm: core: Avoid registering an inaccessible tree
At present there are various restrictions on the use of livetree: - It is only available once the tree is unflattened, i.e. after relocation - It is designed to be used with the control FDT - It can (in principle) be used with other FDTs, but only if they are unflattened first; this is not supported Add a few checks to make sure that any tree that is created is actually valid. Otherwise it can be confusing when nodes and properties cannot actually be accessed. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/ofnode.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index ec574c4460..1d4ab5bb6f 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -60,6 +60,11 @@ static oftree oftree_ensure(void *fdt)
return oftree_null();
}
+ if (of_live_active()) {
+ log_err("Cannot register a flattree when OF_LIVE is active\n");
+ return oftree_null();
+ }
+
/* register the new tree */
i = oftree_count++;
oftree_list[i] = fdt;
@@ -133,6 +138,10 @@ oftree oftree_from_fdt(void *fdt)
if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE))
return oftree_ensure(fdt);
+#ifdef OF_CHECKS
+ if (of_live_active())
+ return oftree_null();
+#endif
tree.fdt = fdt;
return tree;