Browse Source

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>
main
Johannes Beisswenger 2 years ago committed by David Gibson
parent
commit
44bb89cafd
  1. 5
      checks.c

5
checks.c

@ -1767,6 +1767,11 @@ static void check_graph_nodes(struct check *c, struct dt_info *dti, @@ -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 */

Loading…
Cancel
Save