[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH v6 04/19] common/device_tree.c: unflatten_device_tree() propagate errors


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 2 May 2023 16:36:35 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rjb1ox/OK8Kv1DTBbQ9Lbk0Z1Hvt88hsPr+KDuGNW5w=; b=Hz+rdkM/wfTd9fxqtd5x1iefsXZ5mWlTJ5i6ondLuEz2ceyHntIcRRSyW2xPHYCNdoO/FphYeMbP+AZcZoJtHp6s9p4jlAWFXTA3fEcpAXjpfvsf5BTEopY8T35mBYsXyruxraWInqxT8jGrWsrSKsWMfA2SKolXZxiEem64KeSU6hGDMIgXP7f3SEEHOnqi2kq9OOcemoTSZZwNjQGWja1kPKIZaa4d2oav8TC96FZr/MuJG7i68c+62fGEoqhrxj5BnLWdRKyWcpqQeS6ptJtAcZNIInrEI9BYFv6vVal2PGQBwa25PVZ2uW/OHC73Khk//DWjUug+5c1c9n8LhA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ya559k3ytzE58QL3KyvkDHWlCou/EpLMtnHz+AfDNesZbJBVQrHCVd9O/X2sfYs05nR0ZAZjqOqgqkRLwnTBn8PpcVmbtU0aopomIApedhGmB/llatC44tqLNBQcHF2dCqtBKIa8XLArx4gGhnW2qK1RbrGhIGqwPHPmb1s2YNb7D9543ZkB9Zlt+sZJv6s+rdx8Wy87BkrDiJD5I7XsjPtr+Vf9b5F8Q+mFGoFu9ICQkq24m3mQrsWcygnqvnH9icSZR8tERgym2WX49BiGJ8FGcasSlWzdsiSdzlJYWPE/lC+KElJ5/0v8NktQghL2FkC3kM2ZyQKZFZYSCqQ5Mw==
  • Cc: <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Tue, 02 May 2023 23:37:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This will be useful in dynamic node programming when new dt nodes are unflatten
during runtime. Invalid device tree node related errors should be propagated
back to the caller.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
 xen/common/device_tree.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 5daf5197bd..47ab2f7940 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -2071,6 +2071,9 @@ int unflatten_device_tree(const void *fdt, struct 
dt_device_node **mynodes)
     /* First pass, scan for size */
     start = ((unsigned long)fdt) + fdt_off_dt_struct(fdt);
     size = unflatten_dt_node(fdt, 0, &start, NULL, NULL, 0);
+    if ( !size )
+        return -EINVAL;
+
     size = (size | 3) + 1;
 
     dt_dprintk("  size is %#lx allocating...\n", size);
@@ -2088,11 +2091,19 @@ int unflatten_device_tree(const void *fdt, struct 
dt_device_node **mynodes)
     start = ((unsigned long)fdt) + fdt_off_dt_struct(fdt);
     unflatten_dt_node(fdt, mem, &start, NULL, &allnextp, 0);
     if ( be32_to_cpup((__be32 *)start) != FDT_END )
-        printk(XENLOG_WARNING "Weird tag at end of tree: %08x\n",
+    {
+        printk(XENLOG_ERR "Weird tag at end of tree: %08x\n",
                   *((u32 *)start));
+        return -EINVAL;
+    }
+
     if ( be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef )
-        printk(XENLOG_WARNING "End of tree marker overwritten: %08x\n",
+    {
+        printk(XENLOG_ERR "End of tree marker overwritten: %08x\n",
                   be32_to_cpu(((__be32 *)mem)[size / 4]));
+        return -EINVAL;
+    }
+
     *allnextp = NULL;
 
     dt_dprintk(" <- unflatten_device_tree()\n");
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.