]> xenbits.xensource.com Git - xen.git/commitdiff
arm/mm: release grant lock on xenmem_add_to_physmap_one() error paths
authorJan Beulich <jbeulich@suse.com>
Wed, 23 Aug 2017 15:55:38 +0000 (17:55 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 23 Aug 2017 15:55:38 +0000 (17:55 +0200)
Commit 55021ff9ab ("xen/arm: add_to_physmap_one: Avoid to map mfn 0 if
an error occurs") introduced error paths not releasing the grant table
lock. Replace them by a suitable check after the lock was dropped.

This is XSA-235.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
master commit: 59546c1897a90fe9af5ebbbb05ead8d98b4d17b9
master date: 2017-08-23 17:45:45 +0200

xen/arch/arm/mm.c

index 9ca7da4c221db89978ae88318f934e8764c63380..434f73aad071b43bcdab2c8d108c8633863d85c4 100644 (file)
@@ -1052,7 +1052,7 @@ int xenmem_add_to_physmap_one(
             if ( idx < nr_status_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->status[idx]);
             else
-                return -EINVAL;
+                mfn = INVALID_MFN;
         }
         else
         {
@@ -1063,14 +1063,21 @@ int xenmem_add_to_physmap_one(
             if ( idx < nr_grant_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->shared_raw[idx]);
             else
-                return -EINVAL;
+                mfn = INVALID_MFN;
         }
         
-        d->arch.grant_table_gpfn[idx] = gpfn;
+        if ( mfn != INVALID_MFN )
+        {
+            d->arch.grant_table_gpfn[idx] = gpfn;
 
-        t = p2m_ram_rw;
+            t = p2m_ram_rw;
+        }
 
         spin_unlock(&d->grant_table->lock);
+
+        if ( mfn == INVALID_MFN )
+            return -EINVAL;
+
         break;
     case XENMAPSPACE_shared_info:
         if ( idx != 0 )