From patchwork Fri Sep 25 07:41:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 1371085 X-Patchwork-Delegate: sjg@chromium.org 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=pass (p=none dis=none) header.from=st.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.a=rsa-sha256 header.s=STMicroelectronics header.b=O9UoHwND; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ByP4P3NN3z9sSf for ; Fri, 25 Sep 2020 17:41:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 248F0824F9; Fri, 25 Sep 2020 09:41:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.b="O9UoHwND"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C430D824FB; Fri, 25 Sep 2020 09:41:33 +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 mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 34D7A82423 for ; Fri, 25 Sep 2020 09:41:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=patrick.delaunay@st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08P7bn76018153; Fri, 25 Sep 2020 09:41:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=cHqeQ3iWUV+/wErWkTrkCFE3cwr30HVGPkjBlkFT+JM=; b=O9UoHwNDq3xFypFo6FGADuwKS7JkT8VGLCgV5h8DmFmEKT0XaOxb1cnjHkUdmB56tnsh onmLwJHsrpFq8sbdEB4MqVfzDpWPzLixj3hMmXpXE71xjyPiRqNMzfuRcPYCXTSsAuwO 9tqVk74xk8gts8A4Q7m+Gz4ec71CsKtg8ni5JxCPvdEbmolv5UfbVqSJxbMNFeZQ0783 zduOqKevV5PCxA9Z3Punx3bWVuXOWCgmk0pMX6qiFUrsbNYwADmGgdnmOylpPH0wV7Y9 nmQJ8fXw7KXdKaq0qqcb6Z1FkNMBq8zvQipudun9xvyHUeIUP7szcyJOIKqoXyEtOWBW /A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 33n748k6t1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2020 09:41:29 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8FD86100034; Fri, 25 Sep 2020 09:41:28 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 82C9221FE8F; Fri, 25 Sep 2020 09:41:28 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 25 Sep 2020 09:41:28 +0200 From: Patrick Delaunay To: CC: Patrick Delaunay , Simon Glass , U-Boot STM32 Subject: [PATCH 2/3] fdtdec: correct test on return of fdt_node_offset_by_phandle Date: Fri, 25 Sep 2020 09:41:15 +0200 Message-ID: <20200925074116.16068-2-patrick.delaunay@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200925074116.16068-1-patrick.delaunay@st.com> References: <20200925074116.16068-1-patrick.delaunay@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-25_02:2020-09-24, 2020-09-25 signatures=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean The result of fdt_node_offset_by_phandle is negative for error, so this patch corrects the check of this result in fdtdec_parse_phandle_with_args. This patch allows to have the same behavior with or without OF_LIVE for the function dev_read_phandle_with_args with cell_name = NULL and with invalid phandle. Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d3b22ec323..90d7e50646 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -746,7 +746,7 @@ int fdtdec_parse_phandle_with_args(const void *blob, int src_node, if (cells_name || cur_index == index) { node = fdt_node_offset_by_phandle(blob, phandle); - if (!node) { + if (node < 0) { debug("%s: could not find phandle\n", fdt_get_name(blob, src_node, NULL));