[Libvirt-cim] [PATCH 1 of 2] Fix various memory leaks

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Nov 23 22:03:04 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1257988817 28800
# Node ID 9e09e32ad29262203322b5ebac46d45198757a22
# Parent  33a6a50f64e08df1585a249d96d89e4e03d663e4
Fix various memory leaks

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_Device.c
--- a/src/Virt_Device.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_Device.c	Wed Nov 11 17:20:17 2009 -0800
@@ -630,9 +630,9 @@
         else
                 cu_return_instances(results, &list);
 
+ out:
         inst_list_free(&list);
 
- out:
         return s;
 }
 
diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_ElementAllocatedFromPool.c	Wed Nov 11 17:20:17 2009 -0800
@@ -126,10 +126,10 @@
                         inst_list_add(list, inst);
         }
 
+ out:
+        free(poolid);
         inst_list_free(&tmp);
 
- out:
-
         return s;
 }
 
diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_KVMRedirectionSAP.c
--- a/src/Virt_KVMRedirectionSAP.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_KVMRedirectionSAP.c	Wed Nov 11 17:20:17 2009 -0800
@@ -198,6 +198,8 @@
         }
  
  out:
+        free(line);
+
         return s;
 }
 
@@ -497,6 +499,7 @@
         if (port != NULL)
                 free(port->name);
         free(port);
+        cleanup_dominfo(&dominfo);
 
         return s;
 }
diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_ResourceAllocationSettingDataIndication.c
--- a/src/Virt_ResourceAllocationSettingDataIndication.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_ResourceAllocationSettingDataIndication.c	Wed Nov 11 17:20:17 2009 -0800
@@ -121,6 +121,12 @@
         }
 
  out:
+        if (args != NULL)
+                stdi_free_ind_args(&args);
+
+        if (_ctx != NULL)
+                free(_ctx);
+
         return s;
 }
 
diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_ServiceAccessBySAP.c
--- a/src/Virt_ServiceAccessBySAP.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_ServiceAccessBySAP.c	Wed Nov 11 17:20:17 2009 -0800
@@ -42,7 +42,7 @@
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *instance = NULL;
-        char* classname;
+        char *classname = NULL;
 
         if (!match_hypervisor_prefix(ref, info))
                 goto out;
@@ -56,6 +56,8 @@
         s = enum_console_sap(_BROKER, ref, list); 
 
  out:
+        free(classname);
+
         return s;
 }
 
diff -r 33a6a50f64e0 -r 9e09e32ad292 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c	Wed Nov 11 19:54:27 2009 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c	Wed Nov 11 17:20:17 2009 -0800
@@ -1308,7 +1308,9 @@
         s = cdrom_template(ref, template_type, list);
 
  out:
-        free(pfx);
+        free(pfx); 
+        for (i = 0; i < numvolsret; i++)
+                free(volnames[i]);
         free(volnames);
         free(host);
         virStoragePoolFree(poolptr);




More information about the Libvirt-cim mailing list