summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Beisswenger <johannes.beisswenger@cetitec.com>2023-04-14 14:17:38 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2023-05-07 18:47:31 +1000
commit44bb89cafd3d96b8df0f324b652c7bf804b38c05 (patch)
treeeedf3599750284af182d4b357e21dfbf2b10e5e1
parent60bcf1cde1a806fb17dd4c892aff9089f12a8165 (diff)
downloaddevice-tree-compiler-44bb89cafd3d96b8df0f324b652c7bf804b38c05.tar.gz
checks: Fix segmentation fault in check_graph_node
Dts files which contain an 'endpoint' node as a direct child of the root node cause a segmentation fault inside check_graph_node(). This type of error can easily happen when a 'remote-endpoint' property is accidentally placed outside the corresponding endpoint and port nodes. Example with 'endpoint' node: /dts-v1/; / { endpoint {}; }; Example with remote-endpoint property: /dts-v1/; / { foo { remote-endpoint = <0xdeadbeef>; }; }; Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--checks.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/checks.c b/checks.c
index 16bc7f6..8ed7a60 100644
--- a/checks.c
+++ b/checks.c
@@ -1767,6 +1767,11 @@ static void check_graph_nodes(struct check *c, struct dt_info *dti,
get_property(child, "remote-endpoint")))
continue;
+ /* The root node cannot be a port */
+ if (!node->parent) {
+ FAIL(c, dti, node, "root node contains endpoint node '%s', potentially misplaced remote-endpoint property", child->name);
+ continue;
+ }
node->bus = &graph_port_bus;
/* The parent of 'port' nodes can be either 'ports' or a device */