[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 19/19] RFC: hw/virtio: a potential leak fix
From: |
marcandre . lureau |
Subject: |
[PATCH 19/19] RFC: hw/virtio: a potential leak fix |
Date: |
Thu, 28 Mar 2024 14:20:52 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
vhost_svq_get_buf() may return a VirtQueueElement that should be freed.
It's unclear to me if the vhost_svq_get_buf() call should always return NULL.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index cd29cc795b..93742d9ddc 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -414,6 +414,7 @@ static uint16_t vhost_svq_last_desc_of_chain(const
VhostShadowVirtqueue *svq,
return i;
}
+G_GNUC_WARN_UNUSED_RESULT
static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
uint32_t *len)
{
@@ -529,6 +530,7 @@ size_t vhost_svq_poll(VhostShadowVirtqueue *svq, size_t num)
uint32_t r = 0;
while (num--) {
+ g_autofree VirtQueueElement *elem = NULL;
int64_t start_us = g_get_monotonic_time();
do {
@@ -541,7 +543,7 @@ size_t vhost_svq_poll(VhostShadowVirtqueue *svq, size_t num)
}
} while (true);
- vhost_svq_get_buf(svq, &r);
+ elem = vhost_svq_get_buf(svq, &r);
len += r;
}
--
2.44.0
- Re: [PATCH 12/19] migration: fix -Werror=maybe-uninitialized false-positives, (continued)
- [PATCH 13/19] hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/03/28
- [PATCH 14/19] plugins: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/03/28
- [PATCH 15/19] migration: fix -Werror=maybe-uninitialized false-positive, marcandre . lureau, 2024/03/28
- [PATCH 16/19] tests: fix -Werror=maybe-uninitialized, marcandre . lureau, 2024/03/28
- [PATCH 17/19] hw/nvme: fix -Werror=maybe-uninitialized, marcandre . lureau, 2024/03/28
- [PATCH 18/19] hw/virtio: fix -Werror=maybe-uninitialized, marcandre . lureau, 2024/03/28
- [PATCH 19/19] RFC: hw/virtio: a potential leak fix,
marcandre . lureau <=
- Re: [PATCH 00/19] -Werror=maybe-uninitialized fixes, Eric Blake, 2024/03/28