From patchwork Tue Oct 23 03:35:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 988007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fJvH2HDsz9sDb for ; Tue, 23 Oct 2018 14:35:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42fJvD1HyHzDrqN for ; Tue, 23 Oct 2018 14:35:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42fJtt2Nj0zDrq6 for ; Tue, 23 Oct 2018 14:35:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42fJts3vcDz9sN6; Tue, 23 Oct 2018 14:35:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 23 Oct 2018 14:35:22 +1100 Message-Id: <20181023033528.31256-4-alistair@popple.id.au> X-Mailer: git-send-email 2.11.0 Subject: [Pdbg] [PATCH] libpdbg: fix a bug in get_class_target_addr X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" 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 Reviewed-by: Amitay Isaacs --- 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;