Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / vhost / vhost.c
index 33ac2b186b85eb1f4883d26d6d0d9b3a8532fc01..e6bb0946d6e950d4a351c1f1a5b965fef1a32cb5 100644 (file)
@@ -904,7 +904,7 @@ static void vhost_dev_lock_vqs(struct vhost_dev *d)
 {
        int i = 0;
        for (i = 0; i < d->nvqs; ++i)
-               mutex_lock(&d->vqs[i]->mutex);
+               mutex_lock_nested(&d->vqs[i]->mutex, i);
 }
 
 static void vhost_dev_unlock_vqs(struct vhost_dev *d)
@@ -1015,6 +1015,10 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
                vhost_iotlb_notify_vq(dev, msg);
                break;
        case VHOST_IOTLB_INVALIDATE:
+               if (!dev->iotlb) {
+                       ret = -EFAULT;
+                       break;
+               }
                vhost_vq_meta_reset(dev);
                vhost_del_umem_range(dev->iotlb, msg->iova,
                                     msg->iova + msg->size - 1);
@@ -1877,12 +1881,7 @@ static unsigned next_desc(struct vhost_virtqueue *vq, struct vring_desc *desc)
                return -1U;
 
        /* Check they're not leading us off end of descriptors. */
-       next = vhost16_to_cpu(vq, desc->next);
-       /* Make sure compiler knows to grab that: we don't want it changing! */
-       /* We will use the result as an index in an array, so most
-        * architectures only need a compiler barrier here. */
-       read_barrier_depends();
-
+       next = vhost16_to_cpu(vq, READ_ONCE(desc->next));
        return next;
 }