
virt inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICBL3X ------------------------------------------------------------------------ If sched_cpus is successfully allocated but pre_sched_cpus fails to be allocated, the memory of the former is not released. Fixes: 1c342c1a8d0a ("KVM: arm64: Add kvm_vcpu_arch::sched_cpus and pre_sched_cpus") Signed-off-by: Jinqian Yang <yangjinqian1@huawei.com> --- arch/arm64/kvm/hisilicon/hisi_virt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hisilicon/hisi_virt.c b/arch/arm64/kvm/hisilicon/hisi_virt.c index d9029d612697..48a8babb4dae 100644 --- a/arch/arm64/kvm/hisilicon/hisi_virt.c +++ b/arch/arm64/kvm/hisilicon/hisi_virt.c @@ -258,10 +258,14 @@ int kvm_sched_affinity_vcpu_init(struct kvm_vcpu *vcpu) if (!kvm_dvmbm_support) return 0; - if (!zalloc_cpumask_var(&vcpu->arch.sched_cpus, GFP_ATOMIC) || - !zalloc_cpumask_var(&vcpu->arch.pre_sched_cpus, GFP_ATOMIC)) + if (!zalloc_cpumask_var(&vcpu->arch.sched_cpus, GFP_ATOMIC)) return -ENOMEM; + if (!zalloc_cpumask_var(&vcpu->arch.pre_sched_cpus, GFP_ATOMIC)) { + free_cpumask_var(vcpu->arch.sched_cpus); + return -ENOMEM; + } + return 0; } -- 2.33.0