From patchwork Tue Apr 21 18:15:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1274460 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=N+crW2IO; 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 496Bb94qpWz9sSJ for ; Wed, 22 Apr 2020 04:16:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FB3581C5A; Tue, 21 Apr 2020 20:15:59 +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="N+crW2IO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3DE281C54; Tue, 21 Apr 2020 20:15:36 +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,T_SPF_HELO_TEMPERROR,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 C9C16811EC for ; Tue, 21 Apr 2020 20:15:18 +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=37371f929=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=1587492918; x=1619028918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yak2jyF5YGWYRc9R2LkbXyH+sM0RsBas8ti2WUZ/QNE=; b=N+crW2IOTlvaU9BazkOjErFXkmkrFyo0OzNX+8tG+a6eZqtxs2QabbE/ oUKAeUvGQfLj+LQhe6DcTk35M62VK49O6ajK27/FCWFi5Y1IQ6oczWX92 Bh24AQWkTYVk+kTwCXAGRYafnI56YDLoM2ctLljoShziOf7PDQGF3wp7z qjdG1UtDSnoAdCbm0oX0H6HAF41ELJULVaok4JFrhtbdGaATd+zbqCX1X 9gicTFsu/Wf8y9I9l9PLt1Ql9trYzKXn4Ap2iAFriD7M+wzyfm+NYi7+9 oXB0wHY1IgB3gFGmmxB2YMXBeav6QexbZ7v7NahHUKys8ekrkdKwJZUBg A==; IronPort-SDR: cFsj+AAtv+oNr9Zx/gfwlfFaol35kHAWc5QaTUhB3jKxzsvRVUIeuFEY/CVol8ZpG8kv42L51J RzDXdFb5u0VFWhq8WeK/RCRQdc/i7b6dAQ1biYjCC1yD8zYigshZxxTVtNK9NGCW75xCkqmijz A3qrVzH8p0c0md9n/l5WmaLFe3EJXfHr5L+OUyZNunS34rjQk+Qjo5xL0e/3oSL7ahUzsIx6Rt QH3Y8r4DpjyOiWUOxNrpIG0JRHYntk7Edugcm2gSX4U1UuBBcirl0sE/612eOxHaGQvKkjlnG5 KIs= X-IronPort-AV: E=Sophos;i="5.72,411,1580745600"; d="scan'208";a="135816945" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2020 02:15:15 +0800 IronPort-SDR: JScZJDgB/lzPk+eGhlFLfafRGmrmvG+a0blAn0uEcnVKvrhaBR3cepNAYReRXaz87u7HroPucO Z+/PtxfHJYQc6Iev3U/q9iblJePczkqS4= 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; 21 Apr 2020 11:05:33 -0700 IronPort-SDR: at1u8SQrxhf2HDAbmIntjnooTmdp5AgtPpOa2FaXLGGKCXomACwnMrFUOdh7hP5pmc42JwCU2/ /6Nj5eyaY0cQ== WDCIronportException: Internal Received: from usa001638.ad.shared (HELO yoda.hgst.com) ([10.86.55.248]) by uls-op-cesaip01.wdc.com with ESMTP; 21 Apr 2020 11:15:16 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Bin Meng , Anup Patel , Lukas Auer , Heinrich Schuchardt , Rick Chen , palmer@dabbelt.com Subject: [PATCH v7 2/6] fdtdec: Fix boundary check Date: Tue, 21 Apr 2020 11:15:00 -0700 Message-Id: <20200421181504.415822-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200421181504.415822-1-atish.patra@wdc.com> References: <20200421181504.415822-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 9ecfa2a2d743..460f0d250b4d 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;