* [PATCH] virtio: qmp: fix memory leak
@ 2023-05-26 10:24 Paolo Bonzini
2023-05-26 10:26 ` Daniel P. Berrangé
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2023-05-26 10:24 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
The VirtioInfoList is already allocated by QAPI_LIST_PREPEND and
need not be allocated by the caller.
Fixes Coverity CID 1508724.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/virtio/virtio-qmp.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index e84316dcfd21..b5e183529971 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -668,7 +668,7 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bitmap)
VirtioInfoList *qmp_x_query_virtio(Error **errp)
{
VirtioInfoList *list = NULL;
- VirtioInfoList *node;
+ VirtioInfo *node;
VirtIODevice *vdev;
QTAILQ_FOREACH(vdev, &virtio_list, next) {
@@ -682,11 +682,10 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp)
if (!strncmp(is_realized->str, "false", 4)) {
QTAILQ_REMOVE(&virtio_list, vdev, next);
} else {
- node = g_new0(VirtioInfoList, 1);
- node->value = g_new(VirtioInfo, 1);
- node->value->path = g_strdup(dev->canonical_path);
- node->value->name = g_strdup(vdev->name);
- QAPI_LIST_PREPEND(list, node->value);
+ node = g_new(VirtioInfo, 1);
+ node->path = g_strdup(dev->canonical_path);
+ node->name = g_strdup(vdev->name);
+ QAPI_LIST_PREPEND(list, node);
}
g_string_free(is_realized, true);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio: qmp: fix memory leak
2023-05-26 10:24 [PATCH] virtio: qmp: fix memory leak Paolo Bonzini
@ 2023-05-26 10:26 ` Daniel P. Berrangé
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2023-05-26 10:26 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, mst
On Fri, May 26, 2023 at 12:24:53PM +0200, Paolo Bonzini wrote:
> The VirtioInfoList is already allocated by QAPI_LIST_PREPEND and
> need not be allocated by the caller.
>
> Fixes Coverity CID 1508724.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/virtio/virtio-qmp.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-26 10:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26 10:24 [PATCH] virtio: qmp: fix memory leak Paolo Bonzini
2023-05-26 10:26 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).