[PATCH 1/3] checks: Fix segmentation fault in check_graph_node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:
/ {	endpoint {};  };

Example with remote-endpoint property:
/ {
	foo {
                remote-endpoint = <0xdeadbeef>;

Signed-off-by: Johannes Beisswenger <johannes.beisswenger@xxxxxxxxxxx>


this patch series is equivalent to the following GitHub pull request https://github.com/dgibson/dtc/pull/92
which also contains a short summary of the issue.
In short: the segmentation fault happens because check_graph_node() dereferences
node->parent without checking whether it is NULL.

The actual code changes are quite small, nevertheless please let me know if there are any issues.

Best regards
Johannes Beisswenger

Mannheimer Str. 17
D-75179 Pforzheim, Germany 

 checks.c | 5 +++++
 1 file changed, 5 insertions(+)

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")))
+                /* 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 */

[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux