Merge "ANDROID: fuzz: Only check valid phandles" am: 91b7c8d942
am: ec4f0887eb
am: 2b3ff5c1b6
am: a8003860c9
am: f38698893c
Original change: https://android-review.googlesource.com/c/platform/external/dtc/+/2171323 Change-Id: If46ee33ec723fc6e7231ae0e0199446078822510 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
fe1ff3725c
1 changed files with 6 additions and 2 deletions
|
@ -55,6 +55,9 @@ static void check_mem(const void *mem, size_t len) {
|
||||||
#endif
|
#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) {
|
static void walk_node_properties(const void *device_tree, int node) {
|
||||||
int property, len = 0;
|
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);
|
uint32_t phandle = fdt_get_phandle(device_tree, parent_node);
|
||||||
if (phandle != 0) {
|
if (phandle_is_valid(phandle)) {
|
||||||
assert(parent_node == fdt_node_offset_by_phandle(device_tree, 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);
|
walk_node_properties(device_tree, parent_node);
|
||||||
|
|
Loading…
Reference in a new issue