From: "Jan Beulich" Subject: [PATCH] add allocation success checks Date: Fri, 09 Mar 2007 10:14:49 +0000 Message-ID: <45F141A9.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Gerd Hoffmann List-Id: xen-devel@lists.xenproject.org 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 Index: 2007-02-20/xen/arch/x86/domain.c =================================================================== --- 2007-02-20.orig/xen/arch/x86/domain.c 2007-03-08 10:48:03.000000000 +0100 +++ 2007-02-20/xen/arch/x86/domain.c 2007-03-08 10:38:09.000000000 +0100 @@ -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; Index: 2007-02-20/xen/arch/x86/domctl.c =================================================================== --- 2007-02-20.orig/xen/arch/x86/domctl.c 2007-03-08 10:48:03.000000000 +0100 +++ 2007-02-20/xen/arch/x86/domctl.c 2007-03-08 10:31:29.000000000 +0100 @@ -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; }