From 117fdae94b0e8dcb5ab143dc6af5a70d24675c41 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Thu, 26 Jul 2018 23:25:45 +0200 Subject: [PATCH] virtio: fix false-positive assertion failure on virtqueue_req_add_iovs We need to decrement the free_cnt before checking if it reached 0. Note: the vq_free_cnt overflow is asserted at the beginning of the function. Change-Id: I655217785e4425d1cd3c704d24321b643be55dcf Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/420584 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Chandler-Test-Pool: SPDK Automated Test System --- lib/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/virtio/virtio.c b/lib/virtio/virtio.c index 1e2991a1a..94bc48b0c 100644 --- a/lib/virtio/virtio.c +++ b/lib/virtio/virtio.c @@ -548,11 +548,11 @@ virtqueue_req_add_iovs(struct virtqueue *vq, struct iovec *iovs, uint16_t iovcnt vq->req_end = prev_head; vq->vq_desc_head_idx = new_head; + vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - iovcnt); if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END) { assert(vq->vq_free_cnt == 0); vq->vq_desc_tail_idx = VQ_RING_DESC_CHAIN_END; } - vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - iovcnt); } #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc))