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

[Xen-changelog] [xen master] libxc: do proper return code checking of allocator in domain builder



commit fc4ac9284dc93922369084a5c73751658c802ae9
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Dec 1 18:14:54 2015 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Wed Dec 2 15:27:38 2015 +0000

    libxc: do proper return code checking of allocator in domain builder
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxc/xc_dom_core.c |    7 ++++++-
 tools/libxc/xc_dom_x86.c  |   10 ++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index d0c6596..841e7dc 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -630,7 +630,7 @@ xen_pfn_t xc_dom_alloc_page(struct xc_dom_image *dom, char 
*name)
     pfn = dom->pfn_alloc_end - dom->rambase_pfn;
 
     if ( xc_dom_chk_alloc_pages(dom, name, 1) )
-        return (xen_pfn_t)-1;
+        return INVALID_PFN;
 
     DOMPRINTF("%-20s:   %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")",
               __FUNCTION__, name, start, pfn);
@@ -1107,7 +1107,12 @@ int xc_dom_build_image(struct xc_dom_image *dom)
     if ( dom->arch_hooks->alloc_pgtables(dom) != 0 )
         goto err;
     if ( dom->alloc_bootstack )
+    {
         dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack");
+        if ( dom->bootstack_pfn == INVALID_PFN )
+            goto err;
+    }
+
     DOMPRINTF("%-20s: virt_alloc_end : 0x%" PRIx64 "",
               __FUNCTION__, dom->virt_alloc_end);
     DOMPRINTF("%-20s: virt_pgtab_end : 0x%" PRIx64 "",
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 7c77e69..71b042e 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -537,10 +537,20 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
 {
     /* allocate special pages */
     dom->start_info_pfn = xc_dom_alloc_page(dom, "start info");
+    if ( dom->start_info_pfn == INVALID_PFN )
+        return -1;
     dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore");
+    if ( dom->xenstore_pfn == INVALID_PFN )
+        return -1;
     dom->console_pfn = xc_dom_alloc_page(dom, "console");
+    if ( dom->console_pfn == INVALID_PFN )
+        return -1;
     if ( xc_dom_feature_translated(dom) )
+    {
         dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info");
+        if ( dom->shared_info_pfn == INVALID_PFN )
+            return -1;
+    }
     dom->alloc_bootstack = 1;
 
     return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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