From nobody Tue Nov 4 21:46:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531123073162452.7541401978982; Mon, 9 Jul 2018 00:57:53 -0700 (PDT) Received: from localhost ([::1]:39787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcR3P-00073A-S3 for importer@patchew.org; Mon, 09 Jul 2018 03:57:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcQqC-00057Y-AH for qemu-devel@nongnu.org; Mon, 09 Jul 2018 03:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcQqA-0002I9-SD for qemu-devel@nongnu.org; Mon, 09 Jul 2018 03:44:12 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48993) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcQqA-0002EO-Cy; Mon, 09 Jul 2018 03:44:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41PHQT4Nxhz9s8J; Mon, 9 Jul 2018 17:44:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1531122241; bh=imb2UC2WJio8r+bSGauEh1WzzK//ac1XvwROuTAnBzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SsH4mN/snakYIdYny3hUAr27+d3pjwOGgKavT2g+JKqhV7Ai7rU7faIFEOf1OldJw CeTp3L1LYYIA2NVzykIRHRw5CWBekw4FEdXI3rxiT6BGuoO8AoD8m003As/QC8IiBa XWuvs1qgws8cAvVM23cUo13pxoW/NcHTA2kvwZ2U= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 9 Jul 2018 17:43:48 +1000 Message-Id: <20180709074350.27086-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709074350.27086-1-david@gibson.dropbear.id.au> References: <20180709074350.27086-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 14/16] sam460ex: Check for errors from libfdt functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In a couple of places sam460ex_load_device_tree() calls "raw" libfdt functions which can fail, but doesn't check for error codes. At best, if these fail the guest will be silently started in a non-standard state, or it could fail entirely. Fix this by using the _FDT() helper macro which aborts on a libfdt failure. Signed-off-by: David Gibson --- hw/ppc/sam460ex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 7eed2ec601..1661e036f3 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -36,6 +36,7 @@ #include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus.h" #include "hw/usb/hcd-ehci.h" +#include "hw/ppc/fdt.h" =20 #include =20 @@ -318,13 +319,13 @@ static int sam460ex_load_device_tree(hwaddr addr, /* Remove cpm node if it exists (it is not emulated) */ offset =3D fdt_path_offset(fdt, "/cpm"); if (offset >=3D 0) { - fdt_nop_node(fdt, offset); + _FDT(fdt_nop_node(fdt, offset)); } =20 /* set serial port clocks */ offset =3D fdt_node_offset_by_compatible(fdt, -1, "ns16550"); while (offset >=3D 0) { - fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ); + _FDT(fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ)); offset =3D fdt_node_offset_by_compatible(fdt, offset, "ns16550"); } =20 --=20 2.17.1