Free the local variable 'cpumask' when the function is successful. Signed-off-by: Alexandru Elisei --- arm64/kvm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arm64/kvm.c b/arm64/kvm.c index 5f3ed9f6d201..88b3622766bf 100644 --- a/arm64/kvm.c +++ b/arm64/kvm.c @@ -451,7 +451,8 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset) const char *cpulist = arg; cpumask_t *cpumask; size_t setsize; - int cpu, ret; + int ret = 0; + int cpu; kvm->cfg.arch.vcpu_affinity = cpulist; @@ -460,10 +461,8 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset) die_perror("calloc"); ret = cpulist_parse(cpulist, cpumask); - if (ret) { - free(cpumask); - return ret; - } + if (ret) + goto out_free; kvm->arch.vcpu_affinity_cpuset = CPU_ALLOC(NR_CPUS); if (!kvm->arch.vcpu_affinity_cpuset) @@ -474,7 +473,9 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset) for_each_cpu(cpu, cpumask) CPU_SET_S(cpu, setsize, kvm->arch.vcpu_affinity_cpuset); - return 0; +out_free: + free(cpumask); + return ret; } void kvm__arch_validate_cfg(struct kvm *kvm) -- 2.55.0