From ee488e2133e581967d13d5287d7bd654e9b2e2a6 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 2 Jun 2016 14:19:00 +0100 Subject: [PATCH] xen/arm: Don't free p2m->root in p2m_teardown() before it has been allocated If p2m_init() didn't complete successfully, (e.g. due to VMID exhaustion), p2m_teardown() is called and unconditionally tries to free p2m->root before it has been allocated. free_domheap_pages() doesn't tolerate NULL pointers. This is XSA-181 Reported-by: Aaron Cornelius Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Julien Grall --- xen/arch/arm/p2m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 838d004..6a19c57 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1408,7 +1408,8 @@ void p2m_teardown(struct domain *d) while ( (pg = page_list_remove_head(&p2m->pages)) ) free_domheap_page(pg); - free_domheap_pages(p2m->root, P2M_ROOT_ORDER); + if ( p2m->root ) + free_domheap_pages(p2m->root, P2M_ROOT_ORDER); p2m->root = NULL; -- 2.1.4