[PATCH] qemu: Fix memory leaks

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

 



From: Alex Jia <ajia@xxxxxxxxxx>

Detected by Coverity. Leaks introduced in commit 93ab585 and
commit e8d6b29. 

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fbaa824..6a1e7cc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6014,6 +6014,7 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
                 }
                 if (j != ndevices) {
                     ret = -1;
+                    VIR_FREE(devices);
                     continue;
                 }
                 if (qemuDomainMergeDeviceWeights(&vm->def->blkio.devices,
@@ -7867,7 +7868,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     virDomainDefPtr persistentDef = NULL;
     int ret = -1;
     virDomainNetDefPtr net = NULL, persistentNet = NULL;
-    virNetDevBandwidthPtr bandwidth = NULL;
+    virNetDevBandwidthPtr bandwidth = NULL, newBandwidth = NULL;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -7989,8 +7990,6 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     }
 
     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
-        virNetDevBandwidthPtr newBandwidth;
-
         if (VIR_ALLOC(newBandwidth) < 0) {
             virReportOOMError();
             goto cleanup;
@@ -8056,6 +8055,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     ret = 0;
 cleanup:
     virNetDevBandwidthFree(bandwidth);
+    virNetDevBandwidthFree(newBandwidth);
     virCgroupFree(&group);
     if (vm)
         virDomainObjUnlock(vm);
-- 
1.7.1

--
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]