mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-01 14:31:52 -06:00
hw/virtio: freeing leaked memory from vhost_svq_get_buf in vhost_svq_poll
vhost_svq_get_buf() may return a VirtQueueElement that should be freed. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
This commit is contained in:
parent
3073c6b995
commit
95eaaa7690
1 changed files with 3 additions and 1 deletions
|
@ -414,6 +414,7 @@ static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue *svq,
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_GNUC_WARN_UNUSED_RESULT
|
||||||
static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
|
static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
|
||||||
uint32_t *len)
|
uint32_t *len)
|
||||||
{
|
{
|
||||||
|
@ -528,6 +529,7 @@ size_t vhost_svq_poll(VhostShadowVirtqueue *svq, size_t num)
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
while (num--) {
|
while (num--) {
|
||||||
|
g_autofree VirtQueueElement *elem = NULL;
|
||||||
int64_t start_us = g_get_monotonic_time();
|
int64_t start_us = g_get_monotonic_time();
|
||||||
uint32_t r = 0;
|
uint32_t r = 0;
|
||||||
|
|
||||||
|
@ -541,7 +543,7 @@ size_t vhost_svq_poll(VhostShadowVirtqueue *svq, size_t num)
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
vhost_svq_get_buf(svq, &r);
|
elem = vhost_svq_get_buf(svq, &r);
|
||||||
len += r;
|
len += r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue