[Libvirt-cim] [PATCH] Fix potiential seg fault in SDC

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Nov 5 23:10:27 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1225926589 28800
# Node ID 16aa18cf5325f5e689c4967d35288d15825fc2be
# Parent  ece7c71cd2aab612dec19cc6247194cdf8b5b049
Fix potiential seg fault in SDC.

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

diff -r ece7c71cd2aa -r 16aa18cf5325 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c	Wed Nov 05 08:15:51 2008 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c	Wed Nov 05 15:09:49 2008 -0800
@@ -270,6 +270,14 @@
                                   base,
                                   NAMESPACE(ref));
 
+        if (inst == NULL) {
+                cu_statusf(_BROKER, s,
+                           CMPI_RC_ERR_FAILED,
+                           "Unable to create instance of type %s",
+                           base);
+                goto out;
+        }
+
         CMSetProperty(inst, "ResourceType", &resource_type, CMPI_uint16);
 
  out:
@@ -310,6 +318,8 @@
         }
 
         inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_MEM); 
+        if ((inst == NULL) || (s.rc != CMPI_RC_OK))
+                goto out;
 
         CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
         CMSetProperty(inst, "AllocationUnits", 
@@ -395,6 +405,8 @@
         }
 
         inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_PROC); 
+        if ((inst == NULL) || (s.rc != CMPI_RC_OK))
+                goto out;
 
         CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
         CMSetProperty(inst, "AllocationUnits", 
@@ -528,6 +540,8 @@
         }
 
         inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_NET); 
+        if ((inst == NULL) || (s.rc != CMPI_RC_OK))
+                goto out;
 
         CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
         CMSetProperty(inst, "VirtualQuantity", 
@@ -606,6 +620,8 @@
         }
 
         inst = sdc_rasd_inst(&s, ref, CIM_RES_TYPE_DISK);
+        if ((inst == NULL) || (s.rc != CMPI_RC_OK))
+                goto out;
 
         CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars);
         CMSetProperty(inst, "AllocationQuantity",
@@ -632,6 +648,7 @@
 
         inst_list_add(list, inst);
 
+ out:
         return s;
 }
 




More information about the Libvirt-cim mailing list