From 7c78c8542d73eefafff9f9eccb38c986af82394c Mon Sep 17 00:00:00 2001 From: Maldus512 Date: Wed, 14 Jan 2026 14:24:05 +0100 Subject: [PATCH] Added empty node name check The Devicetree specification states that a node name shall be of form `node-name@unit-address` and that the `node-name` component cannot be empty. However, the `dtc` parser considers a node name as a non-empty sequences of the allowed characters plus the @ character, and unit-address extraction is processed after parsing. This has the side effect of considering an empty name plus an address as a valid node name (e.g. `@0`). I've added the node_name_not_empty check, verifying that the `node->basenamelen` is not zero (unless it's the root node). Signed-off-by: Mattia Maldini [dwg: Re-wrap commit message] Signed-off-by: David Gibson --- checks.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/checks.c b/checks.c index 5d09216..45d0213 100644 --- a/checks.c +++ b/checks.c @@ -340,6 +340,14 @@ static void check_node_name_format(struct check *c, struct dt_info *dti, } ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); +static void check_node_name_not_empty(struct check *c, struct dt_info *dti, + struct node *node) +{ + if (node->basenamelen == 0 && node->parent != NULL) + FAIL(c, dti, node, "Empty node name"); +} +ERROR(node_name_not_empty, check_node_name_not_empty, NULL, &node_name_chars); + static void check_node_name_vs_property_name(struct check *c, struct dt_info *dti, struct node *node) @@ -1899,7 +1907,7 @@ WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes); static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, - &node_name_chars, &node_name_format, &property_name_chars, + &node_name_chars, &node_name_format, &node_name_not_empty, &property_name_chars, &name_is_string, &name_properties, &node_name_vs_property_name, &duplicate_label,