Skip to content

Commit

Permalink
virtio: decrement vq->inuse in virtqueue_discard()
Browse files Browse the repository at this point in the history
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 <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
stefanhaRH authored and mstsirkin committed Aug 23, 2016
1 parent bccdef6 commit 58a83c6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions hw/virtio/virtio.c
Expand Up @@ -268,6 +268,7 @@ void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len)
{
vq->last_avail_idx--;
vq->inuse--;
virtqueue_unmap_sg(vq, elem, len);
}

Expand Down

0 comments on commit 58a83c6

Please sign in to comment.