From: Stefan Hajnoczi Date: Mon, 15 Aug 2016 12:54:16 +0000 (+0100) Subject: virtio: decrement vq->inuse in virtqueue_discard() X-Git-Tag: v2.6.2~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca86c04717c23b2155a9366522736995bc9bd772;p=thirdparty%2Fqemu.git virtio: decrement vq->inuse in virtqueue_discard() virtqueue_discard() moves vq->last_avail_idx back so the element can be popped again. It's necessary to decrement vq->inuse to avoid "leaking" the element count. Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 58a83c61496eeb0d31571a07a51bc1947e3379ac) Signed-off-by: Michael Roth --- diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0333bb8bba5..5fbaaaad6e3 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -267,6 +267,7 @@ void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len) { vq->last_avail_idx--; + vq->inuse--; virtqueue_unmap_sg(vq, elem, len); }