[Crosstoolchain-logs] [device-tree-compiler] 21/58: dtc: Fix NULL pointer use in dtlabel + dtref case
Vagrant Cascadian
vagrant at moszumanska.debian.org
Mon Sep 25 16:23:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
vagrant pushed a commit to branch debian/master
in repository device-tree-compiler.
commit 3b9c97093d6e1067f4d24d2bff32f3dd24e0751e
Author: Stephen Boyd <stephen.boyd at linaro.org>
Date: Mon Jan 30 14:06:17 2017 -0800
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 at linaro.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
dtc-parser.y | 6 +++---
tests/run_tests.sh | 1 +
tests/test_label_ref.dts | 9 +++++++++
3 files changed, 13 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;
}
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 157dbae..ed489db 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -511,6 +511,7 @@ dtc_tests () {
run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb
run_dtc_test -I dts -O dtb -o dtc_tree1_merge_path.test.dtb test_tree1_merge_path.dts
tree1_tests dtc_tree1_merge_path.test.dtb test_tree1.dtb
+ run_wrap_error_test $DTC -I dts -O dtb -o /dev/null test_label_ref.dts
# Check prop/node delete functionality
run_dtc_test -I dts -O dtb -o dtc_tree1_delete.test.dtb test_tree1_delete.dts
diff --git a/tests/test_label_ref.dts b/tests/test_label_ref.dts
new file mode 100644
index 0000000..7009c79
--- /dev/null
+++ b/tests/test_label_ref.dts
@@ -0,0 +1,9 @@
+/dts-v1/;
+
+/ {
+
+};
+
+label: &handle {
+
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list