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

[Xen-changelog] [xen-unstable] xen/x86: add allocation success checks.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1173465140 0
# Node ID 2d4df044d7dedfa856601e63af9fcb1120fdfdb6
# Parent  818da23b7571b3f6f6f12bb80658f9a13ed8b8f3
xen/x86: add allocation success checks.

The necessary fix to arch_domain_create() was discovered by Gerd
Hoffmann, but apparently not submitted so far.

Also, adjust two error codes.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/domain.c |    6 ++++--
 xen/arch/x86/domctl.c |   10 ++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff -r 818da23b7571 -r 2d4df044d7de xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Fri Mar 09 18:30:52 2007 +0000
+++ b/xen/arch/x86/domain.c     Fri Mar 09 18:32:20 2007 +0000
@@ -457,8 +457,10 @@ int arch_domain_create(struct domain *d)
  fail:
     free_xenheap_page(d->shared_info);
 #ifdef __x86_64__
-    free_domheap_page(virt_to_page(d->arch.mm_perdomain_l2));
-    free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3));
+    if ( d->arch.mm_perdomain_l2 )
+        free_domheap_page(virt_to_page(d->arch.mm_perdomain_l2));
+    if ( d->arch.mm_perdomain_l3 )
+        free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3));
 #endif
     free_xenheap_pages(d->arch.mm_perdomain_pt, pdpt_order);
     return rc;
diff -r 818da23b7571 -r 2d4df044d7de xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c     Fri Mar 09 18:30:52 2007 +0000
+++ b/xen/arch/x86/domctl.c     Fri Mar 09 18:32:20 2007 +0000
@@ -145,6 +145,12 @@ long arch_do_domctl(
         }
 
         arr32 = alloc_xenheap_page();
+        if ( !arr32 )
+        {
+            ret = -ENOMEM;
+            put_domain(d);
+            break;
+        }
  
         ret = 0;
         for ( n = 0; n < num; )
@@ -157,7 +163,7 @@ long arch_do_domctl(
                                         domctl->u.getpageframeinfo2.array,
                                         n, k) )
             {
-                ret = -EINVAL;
+                ret = -EFAULT;
                 break;
             }
      
@@ -201,7 +207,7 @@ long arch_do_domctl(
             if ( copy_to_guest_offset(domctl->u.getpageframeinfo2.array,
                                       n, arr32, k) )
             {
-                ret = -EINVAL;
+                ret = -EFAULT;
                 break;
             }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
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®.