]> xenbits.xensource.com Git - xen.git/commitdiff
correct gnttab_get_status_frames()
authorJuergen Gross <jgross@suse.com>
Tue, 19 Sep 2017 15:48:23 +0000 (17:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 19 Sep 2017 15:48:23 +0000 (17:48 +0200)
In gnttab_get_status_frames() all accesses to nr_status_frames should
be done with the grant table lock held.

While at it correct coding style: labels should be indented by one
space.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/common/grant_table.c

index c3895e6201c523fa5ea5bfab506c56410e99187e..00ff075bd96b0018d433836c8589a304b2681e27 100644 (file)
@@ -2866,19 +2866,19 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop,
 
     gt = d->grant_table;
 
+    op.status = GNTST_okay;
+
+    grant_read_lock(gt);
+
     if ( unlikely(op.nr_frames > nr_status_frames(gt)) )
     {
         gdprintk(XENLOG_INFO, "Guest requested addresses for %d grant status "
                  "frames, but only %d are available.\n",
                  op.nr_frames, nr_status_frames(gt));
         op.status = GNTST_general_error;
-        goto out2;
+        goto unlock;
     }
 
-    op.status = GNTST_okay;
-
-    grant_read_lock(gt);
-
     for ( i = 0; i < op.nr_frames; i++ )
     {
         gmfn = gnttab_status_gmfn(d, gt, i);
@@ -2886,10 +2886,11 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop,
             op.status = GNTST_bad_virt_addr;
     }
 
+ unlock:
     grant_read_unlock(gt);
-out2:
+ out2:
     rcu_unlock_domain(d);
-out1:
+ out1:
     if ( unlikely(__copy_field_to_guest(uop, &op, status)) )
         return -EFAULT;