x86/mm: Don't dereference p2m pointer before NULL check.
authorTim Deegan <tim@xen.org>
Thu, 12 Sep 2013 08:56:12 +0000 (09:56 +0100)
committerTim Deegan <tim@xen.org>
Thu, 12 Sep 2013 16:47:08 +0000 (17:47 +0100)
Not a security bug, because in fact this is never called with a NULL
argument.

Coverity CID 1055955

Signed-off-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm/p2m.c

index f5ddd208c9bb41172ca8f64637eaceca6b80a6e9..8f380ed8095537dc28f56b9904aef09195321f3d 100644 (file)
@@ -453,7 +453,7 @@ void p2m_teardown(struct p2m_domain *p2m)
  * We know we don't have any extra mappings to these pages */
 {
     struct page_info *pg;
-    struct domain *d = p2m->domain;
+    struct domain *d;
     unsigned long gfn;
     p2m_type_t t;
     mfn_t mfn;
@@ -461,6 +461,8 @@ void p2m_teardown(struct p2m_domain *p2m)
     if (p2m == NULL)
         return;
 
+    d = p2m->domain;
+
     p2m_lock(p2m);
 
     /* Try to unshare any remaining shared p2m entries. Safeguard