Two PVH dom0 series fixes
cover Two PVH dom0 series fixes
Wei Liu (2):
x86: fix memory leak in pvh_setup_acpi_madt
x86: fix memory leak in pvh_setup_acpi_xsdt
xen/arch/x86/domain_build.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/2 x86: fix memory leak in pvh_setup_acpi_madt
Switch to use goto style error handling to avoid leaking madt.
Coverity-ID: 1401534
--- xen/arch/x86/domain_build.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
xen/arch/x86/domain_build.c +12 -5
@@ -2290,7 +2290,8 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)if ( !madt ) {printk ("Unable to allocate memory for MADT table\n" ); -return -ENOMEM ; + rc = -ENOMEM ; + goto out; }/* Copy the native MADT table header. */
@@ -2298,7 +2299,8 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)if ( !ACPI_SUCCESS (status) ) {printk ("Failed to get MADT ACPI table, aborting.\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto out; } madt->header = *table; madt->address =APIC_DEFAULT_PHYS_BASE ;
@@ -2358,7 +2360,8 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)if (pvh_steal_ram (d, size,0 ,GB (4 ), addr) ) {printk ("Unable to find allocate guest RAM for MADT\n" ); -return -ENOMEM ; + rc = -ENOMEM ; + goto out; }/* Mark this region as E820_ACPI. */
@@ -2369,11 +2372,15 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)if ( rc ) {printk ("Unable to copy MADT into guest memory\n" ); -return rc; + goto out; } + + rc =0 ; + + out:xfree (madt); -return 0 ; +return rc; } static bool __init acpi_memory_banned(unsigned long address,
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 x86: fix memory leak in pvh_setup_acpi_xsdt
In reply to Wei LiuSwitch to use goto style error handling to avoid leaking xsdt.
Coverity-ID: 1401535
--- xen/arch/x86/domain_build.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
xen/arch/x86/domain_build.c +14 -6
@@ -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)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/2] x86: fix memory leak in pvh_setup_acpi_madt
In reply to Wei LiuQuoted 1 line · Wei Liu
Switch to use goto style error handling to avoid leaking madt.
Thanks, I guess it's fine to don't leak memory here, but in any case this is doomed to fail, no further progress is going to be made if Dom0 build fails, hence that's why memory leaks here are not really meaningful.
Quoted 3 lines
Coverity-ID: 1401534
Signed-off-by Wei Liu <[email protected]>
Quoted 9 lines
--- xen/arch/x86/domain_build.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)xen/arch/x86/domain_build.c +0
-0
xen/arch/x86/domain_build.c static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr) · line 2294
Quoted 6 lines
xen/arch/x86/domain_build.c +2
-1@@ -2290,7 +2290,8 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)if ( !madt ) {printk ("Unable to allocate memory for MADT table\n" ); -return -ENOMEM ; + rc = -ENOMEM ; + goto out;
This one doesn't need the goto, there's nothing leaked here (although there's also no problem in doing in that way).
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] x86: fix memory leak in pvh_setup_acpi_xsdt
In reply to Wei LiuQuoted 5 lines · Wei Liu
Switch to use goto style error handling to avoid leaking xsdt.
Coverity-ID: 1401535
Signed-off-by Wei Liu <[email protected]>
Thanks! Same comments as the ones in the previous patch, and the first goto is not really needed.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Wei Liu
Wei Liu (2):
x86: fix memory leak inpvh_setup_acpi_madt
x86: fix memory leak inpvh_setup_acpi_xsdtxen/arch/x86/domain_build.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
Reviewed and committed. Thanks,
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel