|
|
29b115 |
From aa99cf129923e0203c0caeb3b4e94a0eb973746f Mon Sep 17 00:00:00 2001
|
|
|
29b115 |
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
|
29b115 |
Date: Thu, 21 Jul 2022 15:36:38 +0200
|
|
|
29b115 |
Subject: [PATCH 04/32] vhost: Fix element in vhost_svq_add failure
|
|
|
29b115 |
MIME-Version: 1.0
|
|
|
29b115 |
Content-Type: text/plain; charset=UTF-8
|
|
|
29b115 |
Content-Transfer-Encoding: 8bit
|
|
|
29b115 |
|
|
|
29b115 |
RH-Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
29b115 |
RH-MergeRequest: 108: Net Control Virtqueue shadow Support
|
|
|
29b115 |
RH-Commit: [4/27] 96689c99a47dd49591c0d126cb1fbb975b2f79b4 (eperezmartin/qemu-kvm)
|
|
|
29b115 |
RH-Bugzilla: 1939363
|
|
|
29b115 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
29b115 |
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
|
29b115 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
29b115 |
|
|
|
29b115 |
Bugzilla: https://bugzilla.redhat.com/1939363
|
|
|
29b115 |
|
|
|
29b115 |
Upstream Status: git://git.qemu.org/qemu.git
|
|
|
29b115 |
|
|
|
29b115 |
commit 5181db132b587754dda3a520eec923b87a65bbb7
|
|
|
29b115 |
Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
29b115 |
Date: Thu May 12 19:57:47 2022 +0200
|
|
|
29b115 |
|
|
|
29b115 |
vhost: Fix element in vhost_svq_add failure
|
|
|
29b115 |
|
|
|
29b115 |
Coverity rightly reports that is not free in that case.
|
|
|
29b115 |
|
|
|
29b115 |
Fixes: Coverity CID 1487559
|
|
|
29b115 |
Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
|
|
|
29b115 |
|
|
|
29b115 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
29b115 |
Message-Id: <20220512175747.142058-7-eperezma@redhat.com>
|
|
|
29b115 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
29b115 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
29b115 |
|
|
|
29b115 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
29b115 |
---
|
|
|
29b115 |
hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++++
|
|
|
29b115 |
1 file changed, 8 insertions(+)
|
|
|
29b115 |
|
|
|
29b115 |
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
29b115 |
index 31fc50907d..06d0bb39d9 100644
|
|
|
29b115 |
--- a/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
29b115 |
+++ b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
29b115 |
@@ -199,11 +199,19 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
|
|
|
29b115 |
return true;
|
|
|
29b115 |
}
|
|
|
29b115 |
|
|
|
29b115 |
+/**
|
|
|
29b115 |
+ * Add an element to a SVQ.
|
|
|
29b115 |
+ *
|
|
|
29b115 |
+ * The caller must check that there is enough slots for the new element. It
|
|
|
29b115 |
+ * takes ownership of the element: In case of failure, it is free and the SVQ
|
|
|
29b115 |
+ * is considered broken.
|
|
|
29b115 |
+ */
|
|
|
29b115 |
static bool vhost_svq_add(VhostShadowVirtqueue *svq, VirtQueueElement *elem)
|
|
|
29b115 |
{
|
|
|
29b115 |
unsigned qemu_head;
|
|
|
29b115 |
bool ok = vhost_svq_add_split(svq, elem, &qemu_head);
|
|
|
29b115 |
if (unlikely(!ok)) {
|
|
|
29b115 |
+ g_free(elem);
|
|
|
29b115 |
return false;
|
|
|
29b115 |
}
|
|
|
29b115 |
|
|
|
29b115 |
--
|
|
|
29b115 |
2.31.1
|
|
|
29b115 |
|