diff mbox

[2/2] x86: fix memory leak in pvh_setup_acpi_xsdt

Message ID 20170226154932.30401-3-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Feb. 26, 2017, 3:49 p.m. UTC
Switch to use goto style error handling to avoid leaking xsdt.

Coverity-ID: 1401535

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/domain_build.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Roger Pau Monné Feb. 27, 2017, 10:17 a.m. UTC | #1
On Sun, Feb 26, 2017 at 03:49:32PM +0000, Wei Liu wrote:
> Switch to use goto style error handling to avoid leaking xsdt.
> 
> Coverity-ID: 1401535
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Thanks! Same comments as the ones in the previous patch, and the first goto is
not really needed.

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
diff mbox

Patch

diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
index 1f18f9283f..d74296509a 100644
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -2459,7 +2459,8 @@  static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr,
     if ( !xsdt )
     {
         printk("Unable to allocate memory for XSDT table\n");
-        return -ENOMEM;
+        rc = -ENOMEM;
+        goto out;
     }
 
     /* Copy the native XSDT table header. */
@@ -2467,7 +2468,8 @@  static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr,
     if ( !rsdp )
     {
         printk("Unable to map RSDP\n");
-        return -EINVAL;
+        rc = -EINVAL;
+        goto out;
     }
     xsdt_paddr = rsdp->xsdt_physical_address;
     acpi_os_unmap_memory(rsdp, sizeof(*rsdp));
@@ -2475,7 +2477,8 @@  static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr,
     if ( !table )
     {
         printk("Unable to map XSDT\n");
-        return -EINVAL;
+        rc = -EINVAL;
+        goto out;
     }
     xsdt->header = *table;
     acpi_os_unmap_memory(table, sizeof(*table));
@@ -2505,7 +2508,8 @@  static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr,
     if ( pvh_steal_ram(d, size, 0, GB(4), addr) )
     {
         printk("Unable to find guest RAM for XSDT\n");
-        return -ENOMEM;
+        rc = -ENOMEM;
+        goto out;
     }
 
     /* Mark this region as E820_ACPI. */
@@ -2516,11 +2520,15 @@  static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr,
     if ( rc )
     {
         printk("Unable to copy XSDT into guest memory\n");
-        return rc;
+        goto out;
     }
+
+    rc = 0;
+
+ out:
     xfree(xsdt);
 
-    return 0;
+    return rc;
 }
 
 static int __init pvh_setup_acpi(struct domain *d, paddr_t start_info)