summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2018-09-04 15:14:57 +1000
committerAlistair Popple <alistair@popple.id.au>2018-11-09 11:20:04 +1100
commit8cc92dbc1d743e3fab72ea418794eafb50d81255 (patch)
tree47692d162dce3fa5e16ab81c053a99b4ac79aa8e
parent45147d21d45ef33cce48d68b946a8b5782b1ec72 (diff)
downloadpdbg-8cc92dbc1d743e3fab72ea418794eafb50d81255.tar.gz
pdbg-8cc92dbc1d743e3fab72ea418794eafb50d81255.zip
libpdbg: fix a bug in get_class_target_addr
The root device tree node does not have a class. Therefore this assert was not useful as the strcmp() may cause a segfault comparing the root node class. Signed-off-by: Alistair Popple <alistair@popple.id.au> Reviewed-by: Amitay Isaacs <amitay@ozlabs.org>
-rw-r--r--libpdbg/target.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libpdbg/target.c b/libpdbg/target.c
index 317a6c6..975ecec 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -24,10 +24,9 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con
*addr += dt_get_address(target, 0, NULL);
target = target->parent;
- /* The should always be a parent. If there isn't it
- * means we traversed up the whole device tree and
- * didn't find a parent matching the given class. */
- assert(target);
+ /* The root node doesn't have an address space so it's
+ * an error in the device tree if we hit this. */
+ assert(target != dt_root);
}
return target;
OpenPOWER on IntegriCloud