xenConfigGetString returns a newly-allocated pointer and it has to be freed by the caller. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- src/xenconfig/xen_common.c | 50 +++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index ab4bb7ff3f..f787827008 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -492,40 +492,41 @@ xenParseCPUFeatures(virConfPtr conf, virDomainXMLOptionPtr xmlopt) { unsigned long count = 0; - const char *str = NULL; + const char *cpus = NULL, *tsc_mode = NULL; int val = 0; virDomainTimerDefPtr timer; + int ret = -1; if (xenConfigGetULong(conf, "vcpus", &count, 1) < 0) - return -1; + goto cleanup; if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0) - return -1; + goto cleanup; if (virDomainDefSetVcpus(def, count) < 0) - return -1; + goto cleanup; if (virConfGetValue(conf, "maxvcpus")) { if (xenConfigGetULong(conf, "maxvcpus", &count, 0) < 0) - return -1; + goto cleanup; if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0) - return -1; + goto cleanup; } - if (xenConfigGetString(conf, "cpus", &str, NULL) < 0) - return -1; + if (xenConfigGetString(conf, "cpus", &cpus, NULL) < 0) + goto cleanup; - if (str && (virBitmapParse(str, &def->cpumask, 4096) < 0)) - return -1; + if (cpus && (virBitmapParse(str, &def->cpumask, 4096) < 0)) + goto cleanup; - if (xenConfigGetString(conf, "tsc_mode", &str, NULL) < 0) - return -1; + if (xenConfigGetString(conf, "tsc_mode", &tsc_mode, NULL) < 0) + goto cleanup; - if (str) { + if (tsc_mode) { if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 || VIR_ALLOC(timer) < 0) - return -1; + goto cleanup; timer->name = VIR_DOMAIN_TIMER_NAME_TSC; timer->present = 1; @@ -544,38 +545,38 @@ xenParseCPUFeatures(virConfPtr conf, if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetBool(conf, "pae", &val, 1) < 0) - return -1; + goto cleanup; else if (val) def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON; if (xenConfigGetBool(conf, "acpi", &val, 1) < 0) - return -1; + goto cleanup; else if (val) def->features[VIR_DOMAIN_FEATURE_ACPI] = VIR_TRISTATE_SWITCH_ON; if (xenConfigGetBool(conf, "apic", &val, 1) < 0) - return -1; + goto cleanup; else if (val) def->features[VIR_DOMAIN_FEATURE_APIC] = VIR_TRISTATE_SWITCH_ON; if (xenConfigGetBool(conf, "hap", &val, 1) < 0) - return -1; + goto cleanup; else if (!val) def->features[VIR_DOMAIN_FEATURE_HAP] = VIR_TRISTATE_SWITCH_OFF; if (xenConfigGetBool(conf, "viridian", &val, 0) < 0) - return -1; + goto cleanup; else if (val) def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] = VIR_TRISTATE_SWITCH_ON; if (xenConfigGetBool(conf, "hpet", &val, -1) < 0) - return -1; + goto cleanup; if (val != -1) { if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 || VIR_ALLOC(timer) < 0) - return -1; + goto cleanup; timer->name = VIR_DOMAIN_TIMER_NAME_HPET; timer->present = val; @@ -587,7 +588,12 @@ xenParseCPUFeatures(virConfPtr conf, } } - return 0; + ret = 0; + + cleanup: + VIR_FREE(cpus); + VIR_FREE(tsc_mode); + return ret; } -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list