When virtqueue_pop fails partway through a batch, the unwind loop
calls virtqueue_unpop on already-popped elements but does not free
them. Each VirtQueueElement was allocated by virtqueue_pop and
must be freed by the caller.
Add g_free after virtqueue_unpop to prevent the leak.
Fixes: 57094547dfea ("virtio-input: fix eventq batching")
Reported-by: Pavee Hui <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
hw/input/virtio-input.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 6494cfbbe82d..dfd2964ae122 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -49,6 +49,7 @@ void virtio_input_send(VirtIOInput *vinput,
virtio_input_event *event)
if (!elem) {
while (--i >= 0) {
virtqueue_unpop(vinput->evt, vinput->queue[i].elem, 0);
+ g_free(vinput->queue[i].elem);
}
vinput->qindex = 0;
trace_virtio_input_queue_full();
--
2.56.0.rc0.29.g47ce80527c56