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

[PATCH 1/2] xen/arm: Fix domain_handle_dtb_bootmodule() error path


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 11 Jul 2023 10:29:30 +0200
  • 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=Dk3lg1kmifrQv5WMidBKQfd64VXe9Ntgkfwp5vhYxrY=; b=l8xePGT4laCgPZk5GHjg4HGin0pnz0wpx30VMUMPfShLvqLr6bXBay9951p3PiK/oaaSxPQMTDeCx9K+bFGDX723t35O5v8YsEjqQm5giw2HWdKIYAHhJHKP+3fgWGxPLBbYie/Jd5yxroWcD8sO8/a2R1aN+ngPqGO6Vr9O4tz081RYnlcvAyOStEhlX39ZZRMyW5+0zZAMrr1tcpeFr8iRusSGxqP8B9le/JdALeq4C3/OdiKY/Ly++nLKuH1nd9B6sI8Ba7SJu04sJMkQiLKgxp0bnLvSzlGae/zix0xbBzPaWVSEvuhEuKX+hNJ7KFlyaH1NGUJKdmLRxifAOg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JhNCSmuNj52GxjfeSx4MF9ZlobOGcqD+ZANrfmmnsStJjICkdhx46OFSnQ+f1Y+xhJmRbwmi8kon/ejOsp/Ws4Nt117+kzC72inXFDavjUaXuBTxS2DeF5nHqI06W5F/5pVbn63waNK+acZVEkR0iA/4xPfHn3vkbZTRjxkSMkQmwbP6ujgBjmz+AmKtM6OXJfgJlL0ccOhNmabwYcT6H3t5R5vlABbBmJZ3M+lycep3oGOPFQpYwKoLtPtYY21yB7G4blO7ANVZwXP9YtAPdEjZWXAf8iSRJ1Cyc0VazPpJg7ZlmrS6rs5c1cciUgfNWFG0wVBTjh6RGjlnILNf+w==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 11 Jul 2023 08:29:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Fix the error path in domain_handle_dtb_bootmodule(), so that the memory
previously mapped is unmapped before returning the error code. This is
because the function shall not make assumptions on the way of handling
its error code in the callers. Today we call panic in case of domU
creation failure, so having memory not unmapped is not a bug, but it can
change.

Similarly, fix prepare_dtb_domU() so that the memory allocated is freed
before returning the error code from domain_handle_dtb_bootmodule().

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/domain_build.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d0d6be922db1..f2134f24b971 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3204,7 +3204,7 @@ static int __init domain_handle_dtb_bootmodule(struct 
domain *d,
 
     res = check_partial_fdt(pfdt, kinfo->dtb_bootmodule->size);
     if ( res < 0 )
-        return res;
+        goto out;
 
     for ( node_next = fdt_first_subnode(pfdt, 0); 
           node_next > 0;
@@ -3235,7 +3235,7 @@ static int __init domain_handle_dtb_bootmodule(struct 
domain *d,
                                  DT_ROOT_NODE_SIZE_CELLS_DEFAULT,
                                  false);
             if ( res )
-                return res;
+                goto out;
             continue;
         }
         if ( dt_node_cmp(name, "passthrough") == 0 )
@@ -3245,11 +3245,12 @@ static int __init domain_handle_dtb_bootmodule(struct 
domain *d,
                                  DT_ROOT_NODE_SIZE_CELLS_DEFAULT,
                                  true);
             if ( res )
-                return res;
+                goto out;
             continue;
         }
     }
 
+ out:
     iounmap(pfdt);
 
     return res;
@@ -3326,7 +3327,7 @@ static int __init prepare_dtb_domU(struct domain *d, 
struct kernel_info *kinfo)
     {
         ret = domain_handle_dtb_bootmodule(d, kinfo);
         if ( ret )
-            return ret;
+            goto err;
     }
 
     ret = make_gic_domU_node(kinfo);
-- 
2.25.1




 


Rackspace

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