xen/arm: Directly return NULL if Xen fails to allocate domain struct
authorJulien Grall <julien.grall@linaro.org>
Fri, 31 Jan 2014 22:22:45 +0000 (22:22 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 4 Feb 2014 14:48:44 +0000 (14:48 +0000)
The current implementation of alloc_domain_struct, dereference the newly
allocated pointer even if the allocation has failed.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain.c

index 635a9a4602840e7a8d4cfb5ba9b583ae49b2ecf6..c279a276c881bd97c9176b7c68a70ae3a181aad0 100644 (file)
@@ -409,8 +409,10 @@ struct domain *alloc_domain_struct(void)
     struct domain *d;
     BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);
     d = alloc_xenheap_pages(0, 0);
-    if ( d != NULL )
-        clear_page(d);
+    if ( d == NULL )
+        return NULL;
+
+    clear_page(d);
     d->arch.grant_table_gpfn = xmalloc_array(xen_pfn_t, max_nr_grant_frames);
     return d;
 }