Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Lots of pedantic error checking in Palacios proper, especially for memory
[palacios.git] / palacios / src / palacios / vmm_cpuid.c
index ca7ef86..06aac52 100644 (file)
@@ -173,6 +173,12 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid,
 
     if (hook == NULL) {
        struct masked_cpuid * mask = V3_Malloc(sizeof(struct masked_cpuid));
+
+       if (!mask) {
+           PrintError("Unable to alocate space for cpu id mask\n");
+           return -1;
+       }
+
        memset(mask, 0, sizeof(struct masked_cpuid));
        
        mask->rax_mask = rax_mask;
@@ -186,6 +192,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid,
 
        if (v3_hook_cpuid(vm, cpuid, mask_hook, mask) == -1) {
            PrintError("Error hooking cpuid %d\n", cpuid);
+           V3_Free(mask);
            return -1;
        }
     } else {
@@ -262,6 +269,12 @@ int v3_hook_cpuid(struct v3_vm_info * vm, uint32_t cpuid,
     }
 
     hook = (struct v3_cpuid_hook *)V3_Malloc(sizeof(struct v3_cpuid_hook));
+
+    if (!hook) {
+       PrintError("Cannot allocate memory to hook cpu id\n");
+       return -1;
+    }
+
     hook->cpuid = cpuid;
     hook->private_data = private_data;
     hook->hook_fn = hook_fn;