diff options
author | Johannes Beisswenger <johannes.beisswenger@cetitec.com> | 2023-04-14 14:17:38 +0200 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2023-05-07 18:47:31 +1000 |
commit | 44bb89cafd3d96b8df0f324b652c7bf804b38c05 (patch) | |
tree | eedf3599750284af182d4b357e21dfbf2b10e5e1 /checks.c | |
parent | 60bcf1cde1a806fb17dd4c892aff9089f12a8165 (diff) | |
download | dtc-44bb89cafd3d96b8df0f324b652c7bf804b38c05.zip dtc-44bb89cafd3d96b8df0f324b652c7bf804b38c05.tar.gz dtc-44bb89cafd3d96b8df0f324b652c7bf804b38c05.tar.bz2 |
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>
Diffstat (limited to 'checks.c')
-rw-r--r-- | checks.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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 */ |