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

[PATCH 2/2] xen/arm: vpl011: Fix domain_vpl011_init error path


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 22 Mar 2023 11:29:41 +0100
  • 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=TyJRc0znxvGeUPenKllUBZbO/z1IN4gNAyJvbD+AGP0=; b=dYRgWtgS0/Zm2wFTbJhECusIlzznLCJ1GsuJKbYRCPOq8Xlx8Lo8msseFxXPdyOXMv4A4WdwpGoSTe2YA2q7wjmLIpFEHkRdsP7uQ5Qu9ICXR5afuEKDKkPIeIOdzETAs7Cc1YrN+MbNqNMHAcoJRmsqEcVwgHR7DczXCTl+m2MnMgxuECDcWRyqznCYTuhyC/bPqqz5FG2MzhimY4IF9KhYoGVMat02EB1er7wFArzjcqnGjNGHAkzNNl3vaReW5QDMa2tSHm2FVJAG2/qpKxlnN5nKYRk7jAznxTsTNB4YkcgOMIcpsAumYmTEKN7xIvisipPItIfZC4IUpATb9Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4C2nVVuNH5Zzivo4wSKC817rApHB3DguqcQW5p81X3E8RDaEmWLeXbM9srrdH/voGYeI2hqRQz5s8nauhO+1b60cqylwpofDGCTMySmRzcMCNeRgsJuhWkZmCjc0sAfQR7g1PC6jU7C37K1GGt4yEZlGizu+qzMUMhlHbbBtGKNoEofj3arJpV+yX9xjgnwBSmWpDo7aAkYn0gAfiM/ZA+G3Kf3Ao4oJ9hQcj/etHWSbWylWD2zVxL/An0Ple3raK4rRz73o72y0BF9WaJDhwOQpIoABycQm9gQ+JpRMfxqBgydUz03LmsPJ+t0d7CBUSZHy3Q0vccKe+HuPGsekg==
  • 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: Wed, 22 Mar 2023 10:30:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When vgic_reserve_virq() fails and backend is in domain, we should also
free the allocated event channel.

When backend is in Xen and call to xzalloc() returns NULL, there is no
need to call xfree(). This should be done instead on an error path
from vgic_reserve_virq(). Also, take the opportunity to return -ENOMEM
instead of -EINVAL when memory allocation fails.

Fixes: 1ee1e4b0d1ff ("xen/arm: Allow vpl011 to be used by DomU")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/vpl011.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 541ec962f189..df29a65ad365 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -696,8 +696,8 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         vpl011->backend.xen = xzalloc(struct vpl011_xen_backend);
         if ( vpl011->backend.xen == NULL )
         {
-            rc = -EINVAL;
-            goto out1;
+            rc = -ENOMEM;
+            goto out;
         }
     }
 
@@ -720,12 +720,15 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
 out2:
     vgic_free_virq(d, vpl011->virq);
 
+    if ( vpl011->backend_in_domain )
+        free_xen_event_channel(d, vpl011->evtchn);
+    else
+        xfree(vpl011->backend.xen);
+
 out1:
     if ( vpl011->backend_in_domain )
         destroy_ring_for_helper(&vpl011->backend.dom.ring_buf,
                                 vpl011->backend.dom.ring_page);
-    else
-        xfree(vpl011->backend.xen);
 
 out:
     return rc;
-- 
2.25.1




 


Rackspace

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