]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Don't free p2m->root in p2m_teardown() before it has been allocated
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 2 Jun 2016 13:19:00 +0000 (14:19 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Jun 2016 10:26:51 +0000 (11:26 +0100)
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 <Aaron.Cornelius@dornerworks.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/p2m.c

index 838d004fb5da6cbf0d596090b15081f91ac9baad..6a19c57d74e3d298b9e4a4c9b0ea1cb07b19e2b9 100644 (file)
@@ -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;