Message ID | 20181023033528.31256-4-alistair@popple.id.au |
---|---|
State | Superseded |
Headers | show |
Series | libpdbg: fix a bug in get_class_target_addr | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | master/apply_patch Successfully applied |
snowpatch_ozlabs/build-multiarch | fail | Test build-multiarch on branch master |
Reviewed-by: Amitay Isaacs <amitay@ozlabs.org> On Tue, 2018-10-23 at 14:35 +1100, Alistair Popple wrote: > 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> > --- > libpdbg/target.c | 7 +++---- > 1 file 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; > -- > 2.11.0 > Amitay.
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;
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> --- libpdbg/target.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)