vhost: fix missing virtqueue status check in async path
authorPatrick Fu <patrick.fu@intel.com>
Tue, 21 Jul 2020 03:35:57 +0000 (11:35 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Jul 2020 14:50:29 +0000 (16:50 +0200)
Vring should not be touched if vq is disabled. This patch adds the vq
status check in async enqueue polling to avoid accessing to a disabled
queue.

Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")

Signed-off-by: Patrick Fu <patrick.fu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/virtio_net.c

index 235c31e..62a5965 100644 (file)
@@ -1689,9 +1689,11 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 
        if (n_pkts_put) {
                vq->async_pkts_inflight_n -= n_pkts_put;
-               __atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE);
-
-               vhost_vring_call_split(dev, vq);
+               if (likely(vq->enabled && vq->access_ok)) {
+                       __atomic_add_fetch(&vq->used->idx,
+                                       n_descs, __ATOMIC_RELEASE);
+                       vhost_vring_call_split(dev, vq);
+               }
        }
 
        if (start_idx + n_pkts_put <= vq_size) {