[v2,5/7] vhost: fix check on virtqueue access in in-flight getter
Checks
Commit Message
Acquiring the access lock is not enough to ensure
virtqueue's metadata such as vring pointers are valid.
The access status must also be checked.
Fixes: 0c0935c5f794 ("vhost: allow to check in-flight packets for async vhost")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/vhost/vhost.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -2073,9 +2073,15 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
return ret;
}
+ if (unlikely(!vq->access_ok)) {
+ ret = -1;
+ goto out_unlock;
+ }
+
if (vq->async)
ret = vq->async->pkts_inflight_n;
+out_unlock:
rte_rwlock_write_unlock(&vq->access_lock);
return ret;