From: Pramod Devendra Date: Mon, 16 Mar 2015 10:06:17 +0000 (+0000) Subject: tools/libxl/libxl_cpuid.c: Fix leak of resstr on error path X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3582 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d79b1c3f1ee10f429a6b4cb59cfd94637bcaca2d;p=xen.git tools/libxl/libxl_cpuid.c: Fix leak of resstr on error path Signed-off-by: Pramod Devendra CC: Ian Jackson CC: Stefano Stabellini CC: Ian Campbell CC: Wei Liu Acked-by: Wei Liu --- diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c index b0bdc9d175..c66e912d92 100644 --- a/tools/libxl/libxl_cpuid.c +++ b/tools/libxl/libxl_cpuid.c @@ -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. */