From patchwork Sat Apr 18 19:32:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1272705 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=JI5MIh7p; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 494NRd0gQrz9sRN for ; Sun, 19 Apr 2020 05:33:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8597981C77; Sat, 18 Apr 2020 21:33:13 +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="JI5MIh7p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 40A1F81C78; Sat, 18 Apr 2020 21:33:07 +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 esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) (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 BCFAB81C51 for ; Sat, 18 Apr 2020 21:33:00 +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=1587238380; x=1618774380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kuk7gYxNo+UDb64Xin7JQNQQTK5FJgDzOdCv/7o68i8=; b=JI5MIh7pCKrNF8uNX30QXgv3rgkzadNp7MhDzSiZvEkAiapd6A68at2k CAebUy4KTJk839kztyLqnoT8knvGpRLiaY3hY/SnHpLUAZ8fcRJn/g19C D7Cg//KKhweITcbehBjswxMwKQ7oGFG8OcKzxPBFbEwp7t8QO7Ae0R3hu QbMAt/WoknzKdj0vzmbqzrXI3axxTFW/6L2CngzW01wFaBEk2PDt1vCn2 NwUGSrDI/tEFk/nLz1yGS47JIE9tIBmjJBCOyCAPUayKGkhJI8zzJpIko HbLK9ttrrwrmfbIK4pPTYJEIHqdOvNZNKvOGxRM+YfYAS6VtXgG/8iaUJ Q==; IronPort-SDR: sPdEj2P02vUs83gXA5+3PsPnOWZ1ZH/aGxUuwV/RyFGFY+fvWz98wx2SQ1zuicpZuAzfdDqZBn 2N/6g1evZKVVvEyqnHb/McUNQ0q5o/TZcrRJBAEzer/S1iGWyp+Bid1WuiiDHv84C31KfeAgS3 b2iQH2nLesUVgDxx8F6soDvrcyU4s/jLGrmNcSE29edPY44VTdDveSFnDsBy/oX/leFzjaKs13 /3u0B5RCFY88wcr+BsK9oam7WFHBl6h32N/5lYV3EJHz2ZZvj3rlxt1iiHUhgY93Y+WK9Xql8b kUU= X-IronPort-AV: E=Sophos;i="5.72,400,1580745600"; d="scan'208";a="244312814" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2020 03:32:41 +0800 IronPort-SDR: 6EsIdYj35Ubrqnwj/3iOrUszID8+2efOGf8XWL56im2cPcCDEpjT9EQTPF9KHlJ+kSLM+CD/xF VZqgkG5sEW2PbZqvkhlvjaQWIaP8m27Eg= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2020 12:23:38 -0700 IronPort-SDR: jF228DW4bKfN6R1EIQbdUhgNRHOvNEFBFaNANPZPDZfDKtNJSui6fdvp2ZZkksevEZcCKN4NkP 9qGej0qWFBXQ== WDCIronportException: Internal Received: from cnf007834.ad.shared (HELO yoda.hgst.com) ([10.86.56.8]) by uls-op-cesaip01.wdc.com with ESMTP; 18 Apr 2020 12:32:41 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Bin Meng , Anup Patel , Lukas Auer , Heinrich Schuchardt , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , Rick Chen , palmer@dabbelt.com Subject: [PATCH v6 2/6] fdtdec: Fix boundary check Date: Sat, 18 Apr 2020 12:32:24 -0700 Message-Id: <20200418193228.44209-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200418193228.44209-1-atish.patra@wdc.com> References: <20200418193228.44209-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 Tested-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;