[libvirt] [PATCH 0/2] fix memory leaks found by valgrind

Pavel Hrdina (2): qemu: fix memory leak and check mdevPath conf: create new RemovalFailed event using correct class src/conf/domain_event.c | 2 +- src/qemu/qemu_command.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) -- 2.12.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 445c696d6e..b3c26d2d80 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5229,11 +5229,13 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, virBuffer buf = VIR_BUFFER_INITIALIZER; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev; char *ret = NULL; + char *mdevPath = NULL; + + if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr))) + goto cleanup; virBufferAddLit(&buf, "vfio-pci"); - virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", - dev->info->alias, - virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)); + virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias, mdevPath); if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0) goto cleanup; @@ -5244,6 +5246,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, ret = virBufferContentAndReset(&buf); cleanup: + VIR_FREE(mdevPath); virBufferFreeAndReset(&buf); return ret; } -- 2.12.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index c15f32a4e6..6e471d7ddb 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -1443,7 +1443,7 @@ virDomainEventDeviceRemovalFailedNew(int id, if (virDomainEventsInitialize() < 0) return NULL; - if (!(ev = virDomainEventNew(virDomainEventDeviceAddedClass, + if (!(ev = virDomainEventNew(virDomainEventDeviceRemovalFailedClass, VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, id, name, uuid))) return NULL; -- 2.12.2

On Fri, Apr 07, 2017 at 14:04:03 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
oops, ACK
participants (2)
-
Pavel Hrdina
-
Peter Krempa