[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] 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@xxxxxxxxxx> --- This is a bug fix for Xen 4.4. Without this patch if Xen run out of memory, it will segfault because it's trying to dereference a NULL pointer. --- xen/arch/arm/domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 635a9a4..c279a27 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -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; } -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |