xen/arm: Directly return NULL if Xen fails to allocate domain struct

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>
This commit is contained in:
Julien Grall authored and Ian Campbell committed 2014-02-04 14:48:44 +00:00
1 parent 46b5f0fd1f
commit ea527eda9e
1 file changed
+4 -2
+4 -2
View 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;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.