[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] vhost: Fix element in vhost_svq_add failure
From: |
Eugenio Pérez |
Subject: |
[PATCH 6/6] vhost: Fix element in vhost_svq_add failure |
Date: |
Thu, 12 May 2022 19:57:47 +0200 |
Coverity rightly reports that is not free in that case.
Fixes: Coverity CID 1487559
Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index a8376ef82b..56c96ebd13 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -199,11 +199,19 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
return true;
}
+/**
+ * Add an element to a SVQ.
+ *
+ * The caller must check that there is enough slots for the new element. It
+ * takes ownership of the element: In case of failure, it is free and the SVQ
+ * is considered broken.
+ */
static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
{
unsigned qemu_head;
bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
if (unlikely(!ok)) {
+ g_free(elem);
return false;
}
--
2.27.0
- [PATCH 0/6] Shadow VirtQueue Fixes, Eugenio Pérez, 2022/05/12
- [PATCH 2/6] vhost: Fix device's used descriptor dequeue, Eugenio Pérez, 2022/05/12
- [PATCH 1/6] vhost: Track descriptor chain in private at SVQ, Eugenio Pérez, 2022/05/12
- [PATCH 3/6] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base, Eugenio Pérez, 2022/05/12
- [PATCH 4/6] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Eugenio Pérez, 2022/05/12
- [PATCH 6/6] vhost: Fix element in vhost_svq_add failure,
Eugenio Pérez <=
- [PATCH 5/6] hw/virtio: Replace g_memdup() by g_memdup2(), Eugenio Pérez, 2022/05/12