[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 48/86] vhost: Fix element in vhost_svq_add failure
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 48/86] vhost: Fix element in vhost_svq_add failure |
Date: |
Mon, 16 May 2022 16:53:24 -0400 |
From: Eugenio Pérez <eperezma@redhat.com>
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>
Message-Id: <20220512175747.142058-7-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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;
}
--
MST
- [PULL v2 38/86] tests/acpi: q35: Allow addition of a CXL test., (continued)
- [PULL v2 38/86] tests/acpi: q35: Allow addition of a CXL test., Michael S. Tsirkin, 2022/05/16
- [PULL v2 39/86] qtests/bios-tables-test: Add a test for CXL emulation., Michael S. Tsirkin, 2022/05/16
- [PULL v2 41/86] qtest/cxl: Add more complex test cases with CFMWs, Michael S. Tsirkin, 2022/05/16
- [PULL v2 40/86] tests/acpi: Add tables for CXL emulation., Michael S. Tsirkin, 2022/05/16
- [PULL v2 42/86] docs/cxl: Add initial Compute eXpress Link (CXL) documentation., Michael S. Tsirkin, 2022/05/16
- [PULL v2 43/86] vhost: Track descriptor chain in private at SVQ, Michael S. Tsirkin, 2022/05/16
- [PULL v2 44/86] vhost: Fix device's used descriptor dequeue, Michael S. Tsirkin, 2022/05/16
- [PULL v2 45/86] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base, Michael S. Tsirkin, 2022/05/16
- [PULL v2 46/86] vdpa: Fix index calculus at vhost_vdpa_svqs_start, Michael S. Tsirkin, 2022/05/16
- [PULL v2 47/86] hw/virtio: Replace g_memdup() by g_memdup2(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 48/86] vhost: Fix element in vhost_svq_add failure,
Michael S. Tsirkin <=
- [PULL v2 49/86] target/i386: Fix sanity check on max APIC ID / X2APIC enablement, Michael S. Tsirkin, 2022/05/16
- [PULL v2 50/86] intel_iommu: Support IR-only mode without DMA translation, Michael S. Tsirkin, 2022/05/16
- [PULL v2 52/86] intel_iommu: Fix irqchip / X2APIC configuration checks, Michael S. Tsirkin, 2022/05/16
- [PULL v2 51/86] intel_iommu: Only allow interrupt remapping to be enabled if it's supported, Michael S. Tsirkin, 2022/05/16
- [PULL v2 56/86] intel-iommu: update iq_dw during post load, Michael S. Tsirkin, 2022/05/16
- [PULL v2 53/86] intel-iommu: remove VTD_FR_RESERVED_ERR, Michael S. Tsirkin, 2022/05/16
- [PULL v2 55/86] intel-iommu: update root_scalable before switching as during post_load, Michael S. Tsirkin, 2022/05/16
- [PULL v2 54/86] intel-iommu: block output address in interrupt address range, Michael S. Tsirkin, 2022/05/16
- [PULL v2 57/86] vhost_net: Print feature masks in hex, Michael S. Tsirkin, 2022/05/16
- [PULL v2 59/86] virtio-pci: add notification trace points, Michael S. Tsirkin, 2022/05/16