From patchwork Tue Mar 24 04:16:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1260450 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=IbyKKCVU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mdJp5ZX7z9sRf for ; Tue, 24 Mar 2020 15:18:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DF7FE81764; Tue, 24 Mar 2020 05:17:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="IbyKKCVU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E242A81822; Tue, 24 Mar 2020 05:17:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0B2DE81776 for ; Tue, 24 Mar 2020 05:17:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=345a454b9=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1585023453; x=1616559453; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=96lFwyOICS6OFVAcNqWnYfdjNQD5DW5eHwTgzw93x9A=; b=IbyKKCVUL/PLg9GBBKncspXhK7fdIL0Hnlwztxym3xtnAnoOYFmQH2or UjlvOfyk4lX34aFn6TZ+D2gVfmqx6NJGz72MN+TvobiJaTBA3F02dcDt0 +1rLkbb0BgTycDrRzAjMUydZUsTJHuJylpAidNYCU6rMiuaq4DP6YONp0 I3XrbULf6o1pRPg7Uxy/KfN7qqbplKwzXTHevPMaefQMfPNVS+z5x7rRV dOVWNC7K2ETx//HDONU8qyU6pDKZL0E1d1pcOCfNMKlKmxxrsKyGkxe4D n+DzHiVtUMUV0GKtMjCxG7OzKwD6fZXRiHDu2mvQtatIfMlVRMs1i/ip0 w==; IronPort-SDR: Y9VPtxVPAqQuo+IjPaDxv/QTOYFd4SteUYNt+s2FpO5SoH0epzxG5S/eWXuciOZ5rftPxJOoQR kk0PJuUkxHRfDOlPZJGP2yoSXwOj4iCjD0RqmUCFhO5GujPwys1ndm6DUQau6Cq7XefUP2I503 jrxHjcNPwMglNRx1z1adl1oswezs8Eo0u8eL5XY/bSGebUuYjSwSikjFTH42eKZ6Z4/tJ7GB/E 9NpjeB6NMnGEM2TmpkThqKZQpovxwqF4atkrvHHos87a3dspDBpgGhFjuA+hOgtvx6tmPFYIaO Qhk= X-IronPort-AV: E=Sophos;i="5.72,298,1580745600"; d="scan'208";a="235522565" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 24 Mar 2020 12:17:29 +0800 IronPort-SDR: iqT/pIkCHrHP9zlhHhRCeLmo0LuFBVGb4nAhzNCFM+62Q6u/CItU07yD1Lb62lj0ky1QJX8pkv Dq7t8WRndjMD94FG5unKFtr1+Vglfg+pyHuGmzPv8lIyUiZfLyRZ1JjWKtRHeahKUWA3TiLLzA CBTIx4p8XP7VMd/bpWgvoEqu5ZlFfV9Kf+Uqe6H4WL/byt6B6rjgC4mjr9CY/7PGAsOYK9tuEw CcR/CE/FNKn7nj0cd8kXKJNm9NDHTrvDp6Y9B8fdNjD//3Mq1HCxt8ejWlSFl8ewG7PrQUTLaV IZcpe8nUoRpTgWQbpBCw7Nyp Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 21:08:48 -0700 IronPort-SDR: aybvp6XXk/Im2ANFKoHXBCjocYisjCgCPxs3Wg1Yhlxd3y6dRqLQOBxSXeOm9HtecOZe2l5N2f TBNHhn8zldTyY2LoQRauZNVeGvbSGVDAE1RH6azPs46CQkw293yb0hO0CWH+jbqOnZfBktWo4C hXCqbrk05MCUTX1d0/T02R5g1kshvWpmLuvENPXRy8j7J8sII8d7LQuRLrJacy60eXIzDDp2h9 x0mTHKWB6CoCBBbcT69yBgj+Aok3d/UihBQ0yQyAZxFYAFtpfPikryl66fQ6OXwAeQJ1fxmuh8 Czk= WDCIronportException: Internal Received: from cm122g2.ad.shared (HELO yoda.hgst.com) ([10.86.54.193]) by uls-op-cesaip02.wdc.com with ESMTP; 23 Mar 2020 21:17:07 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Rick Chen , abner.chang@hpe.com, daniel.schaefer@hpe.com, Thierry Reding Subject: [PATCH v4 2/6] fdtdec: Fix boundary check Date: Mon, 23 Mar 2020 21:16:46 -0700 Message-Id: <20200324041650.280302-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324041650.280302-1-atish.patra@wdc.com> References: <20200324041650.280302-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean In U-Boot, the reserved memory end address is considered as a inclusive address. This notion is followed while adding a reserved memory node to the DT. For example: end_address = start_address + size - 1 Follow the same notion and fix the end address computation while checking for existing nodes. Signed-off-by: Atish Patra --- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index eb11fc898e30..07ba9f5c97e9 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1311,7 +1311,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, continue; } - if (addr == carveout->start && (addr + size) == carveout->end) { + if (addr == carveout->start && (addr + size - 1) == + carveout->end) { if (phandlep) *phandlep = fdt_get_phandle(blob, node); return 0;