]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: Avoid NULL dereference when checking altp2m's for shareability
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jul 2016 17:54:16 +0000 (18:54 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 1 Aug 2016 16:44:32 +0000 (17:44 +0100)
Coverity identifies that __get_gfn_type_access() unconditionally writes to its
type parameter under a number of circumstances.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/mem_sharing.c

index 47e08209eb7aaaadf24ce3def9e6b5e450d13b0a..14952ce76ca65dff828953c45a5ed17923dc82e0 100644 (file)
@@ -870,6 +870,7 @@ int mem_sharing_nominate_page(struct domain *d,
         unsigned int i;
         struct p2m_domain *ap2m;
         mfn_t amfn;
+        p2m_type_t ap2mt;
         p2m_access_t ap2ma;
 
         altp2m_list_lock(d);
@@ -880,7 +881,7 @@ int mem_sharing_nominate_page(struct domain *d,
             if ( !ap2m )
                 continue;
 
-            amfn = get_gfn_type_access(ap2m, gfn, NULL, &ap2ma, 0, NULL);
+            amfn = get_gfn_type_access(ap2m, gfn, &ap2mt, &ap2ma, 0, NULL);
             if ( mfn_valid(amfn) && (mfn_x(amfn) != mfn_x(mfn) || ap2ma != p2ma) )
             {
                 altp2m_list_unlock(d);