From patchwork Sat Feb 13 16:28:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 582430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1D7A81400CB for ; Sun, 14 Feb 2016 03:29:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751101AbcBMQ3P (ORCPT ); Sat, 13 Feb 2016 11:29:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37942 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103AbcBMQ2t (ORCPT ); Sat, 13 Feb 2016 11:28:49 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id C363B2620; Sat, 13 Feb 2016 16:28:49 +0000 (UTC) Received: from hawk.localdomain.com (ovpn-204-32.brq.redhat.com [10.40.204.32]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1DGSWlA016393; Sat, 13 Feb 2016 11:28:47 -0500 From: Andrew Jones To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: thuth@redhat.com, dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de, lvivier@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH v3 04/17] devicetree: fix dt_get_memory_params Date: Sat, 13 Feb 2016 17:28:17 +0100 Message-Id: <1455380910-30604-5-git-send-email-drjones@redhat.com> In-Reply-To: <1455380910-30604-1-git-send-email-drjones@redhat.com> References: <1455380910-30604-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Index nr was overreaching with its indexing. It should only index the caller's regs array. We need a different index for the memory nodes' reg properties. Signed-off-by: Andrew Jones Reviewed-by: Thomas Huth --- The next patch needs this fix. --- lib/devicetree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/devicetree.c b/lib/devicetree.c index 36cb28610ff41..a5c7f7c69ddfd 100644 --- a/lib/devicetree.c +++ b/lib/devicetree.c @@ -165,22 +165,24 @@ int dt_pbus_get_base_compatible(const char *compatible, int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs) { const char *pn = "device_type", *pv = "memory"; - int node, ret, pl = strlen(pv) + 1, nr = 0; + int node, ret, reg_idx, pl = strlen(pv) + 1, nr = 0; struct dt_pbus_reg reg; node = fdt_node_offset_by_prop_value(fdt, -1, pn, pv, pl); while (node >= 0) { + reg_idx = 0; + while (nr < nr_regs) { - ret = dt_pbus_translate_node(node, nr, ®); + ret = dt_pbus_translate_node(node, reg_idx, ®); if (ret == -FDT_ERR_NOTFOUND) break; if (ret < 0) return ret; regs[nr].addr = reg.addr; regs[nr].size = reg.size; - ++nr; + ++nr, ++reg_idx; } node = fdt_node_offset_by_prop_value(fdt, node, pn, pv, pl);