tools/libxl/libxl_cpuid.c: Fix leak of resstr on error path
authorPramod Devendra <pramod.devendra@citrix.com>
Mon, 16 Mar 2015 10:06:17 +0000 (10:06 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 18 Mar 2015 12:06:54 +0000 (12:06 +0000)
Signed-off-by: Pramod Devendra <pramod.devendra@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_cpuid.c

index b0bdc9d17598bd184fef88beb8bd35359b56b759..c66e912d92e9be3c1a95d1a7c5c389863c2da989 100644 (file)
@@ -223,9 +223,6 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
     }
     entry = cpuid_find_match(cpuid, flag->leaf, flag->subleaf);
     resstr = entry->policy[flag->reg - 1];
-    if (resstr == NULL) {
-        resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
-    }
     num = strtoull(val, &endptr, 0);
     flags[flag->length] = 0;
     if (endptr != val) {
@@ -242,6 +239,11 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
             return 3;
         }
     }
+
+    if (resstr == NULL) {
+        resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+    }
+
     /* the family and model entry is potentially split up across
      * two fields in Fn0000_0001_EAX, so handle them here separately.
      */