From patchwork Thu Apr 7 15:17:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mugunthan V N X-Patchwork-Id: 607436 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qgmRz5GL9z9t3t for ; Fri, 8 Apr 2016 01:17:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CC6F4B37F2; Thu, 7 Apr 2016 17:17:39 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ducN9iLORLcY; Thu, 7 Apr 2016 17:17:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B394EA7550; Thu, 7 Apr 2016 17:17:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 38D86B37F2 for ; Thu, 7 Apr 2016 17:17:28 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k_ETp6T_V5dG for ; Thu, 7 Apr 2016 17:17:28 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id 8CF2CA7498 for ; Thu, 7 Apr 2016 17:17:22 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u37FHJH2010030; Thu, 7 Apr 2016 10:17:19 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u37FHJpF014557; Thu, 7 Apr 2016 10:17:19 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 7 Apr 2016 10:17:19 -0500 Received: from a0131834lt.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u37FHB3d009138; Thu, 7 Apr 2016 10:17:17 -0500 From: Mugunthan V N To: Date: Thu, 7 Apr 2016 20:47:01 +0530 Message-ID: <1460042230-15205-3-git-send-email-mugunthanvnm@ti.com> X-Mailer: git-send-email 2.8.1.101.g72d917a In-Reply-To: <1460042230-15205-1-git-send-email-mugunthanvnm@ti.com> References: <1460042230-15205-1-git-send-email-mugunthanvnm@ti.com> MIME-Version: 1.0 Cc: Tom Rini , Sekhar Nori , Joe Hershberger Subject: [U-Boot] [PATCH 02/11] lib: fdtdec: fix size cell and address cell parse from DT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Size cell and address cell should be read from the parent node and should not assume with data structures as an example TI DRA7xx SoC is enabled as 64bit as there is LPAE support but the addresses specified in DT are all 32 bit sizes. So changing the code to read from parent node instead of calculations. Signed-off-by: Mugunthan V N --- lib/fdtdec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 70acc29..8a5fb8c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -88,15 +88,20 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, const fdt32_t *prop_addr, *prop_size, *prop_after_size; int len; fdt_addr_t addr; + int parent; debug("%s: %s: ", __func__, prop_name); - if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) { + parent = fdt_parent_offset(blob, node); + + na = fdt_address_cells(blob, parent); + if (na < 1) { debug("(na too large for fdt_addr_t type)\n"); return FDT_ADDR_T_NONE; } - if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) { + ns = fdt_size_cells(blob, parent); + if (ns < 0) { debug("(ns too large for fdt_size_t type)\n"); return FDT_ADDR_T_NONE; }