[PATCH 2/2] libxl: Resolve Coverity RESOURCE_LEAK

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

 



Commit id 'f9edcfa4' added cookie manipulation for libxl; however, some
cookie crumb cleanup was missed.

In libxlDomainMigrationBegin, the cookie is allocated and baked; however,
the mig ingredients weren't cleaned up.

In libxlDomainMigrationPrepare, when the 'mig' cookie is added to the
args, set the 'mig = NULL'; otherwise, other failure paths between when
the code ate the cookie data and when it was added to args would fail
to clean up the crumbs.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/libxl/libxl_migration.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index ad54960..a809aa0 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -402,7 +402,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
 {
     libxlDriverPrivatePtr driver = conn->privateData;
     libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
-    libxlMigrationCookiePtr mig;
+    libxlMigrationCookiePtr mig = NULL;
     virDomainDefPtr tmpdef = NULL;
     virDomainDefPtr def;
     char *xml = NULL;
@@ -440,6 +440,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
         vm = NULL;
 
  cleanup:
+    libxlMigrationCookieFree(mig);
     if (vm)
         virObjectUnlock(vm);
 
@@ -601,6 +602,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
     args->socks = socks;
     args->nsocks = nsocks;
     args->migcookie = mig;
+    mig = NULL;
 
     for (i = 0; i < nsocks; i++) {
         if (virNetSocketSetBlocking(socks[i], true) < 0)
@@ -640,6 +642,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
     }
 
  done:
+    libxlMigrationCookieFree(mig);
     if (!uri_in)
         VIR_FREE(hostname);
     else
-- 
2.5.5

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