[PATCH 1/2] qemu: fix memory leak and check mdevPath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux