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>
This commit is contained in:
committed by
David Gibson
parent
43eb551426
commit
3b9c97093d
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user