summaryrefslogtreecommitdiff
path: root/fuzzing
diff options
context:
space:
mode:
Diffstat (limited to 'fuzzing')
-rw-r--r--fuzzing/libfdt_fuzzer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fuzzing/libfdt_fuzzer.c b/fuzzing/libfdt_fuzzer.c
index f89f1b4..48b50aa 100644
--- a/fuzzing/libfdt_fuzzer.c
+++ b/fuzzing/libfdt_fuzzer.c
@@ -55,6 +55,9 @@ static void check_mem(const void *mem, size_t len) {
#endif
}
+static bool phandle_is_valid(uint32_t phandle) {
+ return phandle != 0 && phandle != UINT32_MAX;
+}
static void walk_node_properties(const void *device_tree, int node) {
int property, len = 0;
@@ -77,8 +80,9 @@ static void walk_device_tree(const void *device_tree, int parent_node) {
}
uint32_t phandle = fdt_get_phandle(device_tree, parent_node);
- if (phandle != 0) {
- assert(parent_node == fdt_node_offset_by_phandle(device_tree, phandle));
+ if (phandle_is_valid(phandle)) {
+ int node = fdt_node_offset_by_phandle(device_tree, phandle);
+ assert(node >= 0); // it should at least find parent_node
}
walk_node_properties(device_tree, parent_node);