Received: from eggs.gnu.org ([2001:4830:134:3::10]:43615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmOUw-0007WK-P4 for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:06:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmOUr-0007ZB-NM for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:06:22 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmOUr-0007YH-Aw for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:06:17 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8KH3Kkm107606 for ; Tue, 20 Sep 2016 13:06:16 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 25k0w3vtd0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 20 Sep 2016 13:06:16 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Sep 2016 11:06:15 -0600 From: Michael Roth Date: Tue, 20 Sep 2016 12:05:20 -0500 In-Reply-To: <1474391141-16623-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1474391141-16623-1-git-send-email-mdroth@linux.vnet.ibm.com> Message-Id: <1474391141-16623-5-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 04/25] virtio: decrement vq->inuse in virtqueue_discard() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Stefan Hajnoczi , "Michael S. Tsirkin" From: Stefan Hajnoczi 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 --- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0333bb8..5fbaaaa 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); } -- 1.9.1