|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] dt-overlay: Ignore nodes that do not have __overlay__ as their subnode
commit 239b0c8f065dfd044e88815875ec4e24f600ba76
Author: Michal Orzel <michal.orzel@xxxxxxx>
AuthorDate: Fri Oct 4 14:22:19 2024 +0200
Commit: Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Thu Oct 10 16:18:56 2024 +0100
dt-overlay: Ignore nodes that do not have __overlay__ as their subnode
Assumption stated in the comments as if fdt_for_each_subnode() checks
for parent < 0 is utterly wrong. If parent is < 0, node offset is set to
0 (i.e. the very first node in the tree) and the loop's body is executed.
This incorrect assumption causes overlay_node_count() to also count nodes
that do not have __overlay__ as their subnode. The same story goes for
overlay_get_nodes_info(), where we end up requiring each node directly
under root node to have "target-path" set. DTBOs can specify other nodes
including special ones like __symbols__, __fixups__ that can be left to
reduce the number of steps a user needs to do to when it comes to invalid
phandles.
Fix it by adding checks if overlay < 0 after respective calls to
fdt_subnode_offset().
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
xen/common/dt-overlay.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c
index bfa1532509..4d75b5b36a 100644
--- a/xen/common/dt-overlay.c
+++ b/xen/common/dt-overlay.c
@@ -274,11 +274,9 @@ static unsigned int overlay_node_count(const void
*overlay_fdt)
int overlay;
overlay = fdt_subnode_offset(overlay_fdt, fragment, "__overlay__");
+ if ( overlay < 0 )
+ continue;
- /*
- * overlay value can be < 0. But fdt_for_each_subnode() loop checks for
- * overlay >= 0. So, no need for a overlay>=0 check here.
- */
fdt_for_each_subnode(subnode, overlay_fdt, overlay)
{
num_overlay_nodes++;
@@ -305,6 +303,10 @@ static int overlay_get_nodes_info(const void *fdto, char
**nodes_full_path)
int subnode;
const char *target_path;
+ overlay = fdt_subnode_offset(fdto, fragment, "__overlay__");
+ if ( overlay < 0 )
+ continue;
+
target = fdt_overlay_target_offset(device_tree_flattened, fdto,
fragment, &target_path);
if ( target < 0 )
@@ -313,12 +315,6 @@ static int overlay_get_nodes_info(const void *fdto, char
**nodes_full_path)
if ( target_path == NULL )
return -EINVAL;
- overlay = fdt_subnode_offset(fdto, fragment, "__overlay__");
-
- /*
- * overlay value can be < 0. But fdt_for_each_subnode() loop checks for
- * overlay >= 0. So, no need for a overlay>=0 check here.
- */
fdt_for_each_subnode(subnode, fdto, overlay)
{
const char *node_name = NULL;
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |