KVM: fix memoryleak in kvm_init()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 23 Aug 2022 06:34:14 +0000 (14:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:49:04 +0000 (08:49 +0100)
commit5588657f418c1edb5390710863429f4393518a9c
treef3c1db955330f309fd428dcb7ed8c50fd63501e8
parent4441a90091931fd81607567961dc122f24f735bb
KVM: fix memoryleak in kvm_init()

commit 5a2a961be2ad6a16eb388a80442443b353c11d16 upstream.

When alloc_cpumask_var_node() fails for a certain cpu, there might be some
allocated cpumasks for percpu cpu_kick_mask. We should free these cpumasks
or memoryleak will occur.

Fixes: baff59ccdc65 ("KVM: Pre-allocate cpumasks for kvm_make_all_cpus_request_except()")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Link: https://lore.kernel.org/r/20220823063414.59778-1-linmiaohe@huawei.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c