diff options
author | Stephen Boyd <stephen.boyd@linaro.org> | 2017-01-30 14:06:17 -0800 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-01-31 09:50:22 +1100 |
commit | 3b9c97093d6e1067f4d24d2bff32f3dd24e0751e (patch) | |
tree | 33661acd3aae1a35391cbbef4efdf1a19b19c497 /dtc-parser.y | |
parent | 43eb551426ea05186ea07140ad4e277eb253c32c (diff) | |
download | dtc-3b9c97093d6e1067f4d24d2bff32f3dd24e0751e.tar.gz |
dtc: Fix NULL pointer use in dtlabel + dtref case
If we have a construct like this:
label: &handle {
...
};
Running dtc on it will cause a segfault, because we use 'target'
when it could be NULL. Move the add_label() call into the if
statement to fix this potentially bad use of a NULL pointer.
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r-- | dtc-parser.y | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/dtc-parser.y b/dtc-parser.y index b2fd4d1..ca3f500 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -171,10 +171,10 @@ devicetree: { struct node *target = get_node_by_ref($1, $3); - add_label(&target->labels, $2); - if (target) + if (target) { + add_label(&target->labels, $2); merge_nodes(target, $4); - else + } else ERROR(&@3, "Label or path %s not found", $3); $$ = $1; } |