From patchwork Sat Apr 18 06:07:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1272566 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=85.214.62.61; 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=IEK1ecBZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4942dJ5DFDz9sP7 for ; Sat, 18 Apr 2020 16:10:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9251E819FD; Sat, 18 Apr 2020 08:10:34 +0200 (CEST) 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="IEK1ecBZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C97CB81756; Sat, 18 Apr 2020 08:10:27 +0200 (CEST) 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 esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) (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 A935C80574 for ; Sat, 18 Apr 2020 08:10:21 +0200 (CEST) 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=370d05252=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=1587190222; x=1618726222; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=96lFwyOICS6OFVAcNqWnYfdjNQD5DW5eHwTgzw93x9A=; b=IEK1ecBZCIzT7CdrPAbTYCKG8Xo+BjAPX0DcJyy5JGnLPB+f38M0VmKc E/OBLh0lyD4HEsG/aFKbDoJoJwBE/c0IVa2nYoFt9BVcQkhb0gNLZXKAr ifxs59y/BTzTdPOwicPa/T61SwTKx+ykOLwxxsJCVTfnfYmER9sy9WB9h gzS3TU9Ot1W/JzCigyzIR13zv1Zw41iiKqZq4vajqKVvQxs8foSfpaJ15 G4LC8792w5Yq025vsEIqkQVwRGRn8N42I0PIeUpNNcXRrDBeRCQlQEIX+ v5rZfGcAwsdxozFHMM9zjI7pN+J9sM6YB9DOhEz52smSncqTwIkdeQ7fu A==; IronPort-SDR: ynJxC9D5CcZ6zbvaSLikFio4lBg1WvXP/lclWPKsimg4eE1qN2/MWK5PwlFmDJb5avdB8uTmNO xl8XzgSv1nVc2CG37bDFA1SMeCBXcUTzubtNHmuMSfA/DUHZ1aQDDNpNXx65pyhUG7+XOzZAtO 8iDOGau6eVORfWK0dIxcljqTpIJKttJkhunSOrmuKScSQ47MDHhJFI+wgz94Idv0CpyJ8tju7t l699wIG2EV690bsMRfp0GFeCp5bSnxpabEUgGUkrRUDS4TCtzrsAib+K0Nj4QzldhH1kPT+sg+ 69Y= X-IronPort-AV: E=Sophos;i="5.72,397,1580745600"; d="scan'208";a="139952072" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Apr 2020 14:10:17 +0800 IronPort-SDR: R5rD17VuYc87qkEqewVPxc+TYopbsjShM4/E/YBmFLTXJmevWgi+Dec6oRDplTBBNDKPbS7uNB 3+kEzQLhriwaPHL6ytkOHiC3NeRrU1MkQ= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2020 23:00:41 -0700 IronPort-SDR: LdAhdeCi6ip8D66rOOzK/gvszVs4NAhMfCxbElbcMGS8wDvMh2I2dj+KlYpzPwSUW2k7qMOblG tmZY1NVE3IZg== WDCIronportException: Internal Received: from 5s19j72.ad.shared (HELO yoda.hgst.com) ([10.86.56.13]) by uls-op-cesaip01.wdc.com with ESMTP; 17 Apr 2020 23:10:17 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Anup Patel , Bin Meng , Lukas Auer , Heinrich Schuchardt , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , Rick Chen , palmer@dabbelt.com Subject: [RESEND PATCH v5 2/6] fdtdec: Fix boundary check Date: Fri, 17 Apr 2020 23:07:54 -0700 Message-Id: <20200418060758.4839-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200418060758.4839-1-atish.patra@wdc.com> References: <20200418060758.4839-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 Reviewed-by: Bin Meng --- 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;