diff options
author | Miaohe Lin <linmiaohe@huawei.com> | 2022-08-23 14:34:14 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-05 11:23:43 +0200 |
commit | 34ef9cd887d573babd5b7f689fc188eff14aa8ed (patch) | |
tree | a5a9cc71a008c5dd4199f803a0a112b1ec614b80 | |
parent | a6d345c3a31e1eaef6dbccfd57166a4da97c6dfe (diff) | |
download | linux-stable-34ef9cd887d573babd5b7f689fc188eff14aa8ed.tar.gz linux-stable-34ef9cd887d573babd5b7f689fc188eff14aa8ed.tar.bz2 linux-stable-34ef9cd887d573babd5b7f689fc188eff14aa8ed.zip |
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>
-rw-r--r-- | virt/kvm/kvm_main.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d2df08102171..356fd5d1a428 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5014,7 +5014,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, r = kvm_async_pf_init(); if (r) - goto out_free_5; + goto out_free_4; kvm_chardev_ops.owner = module; kvm_vm_fops.owner = module; @@ -5047,10 +5047,9 @@ err_register: kvm_vfio_ops_exit(); err_vfio: kvm_async_pf_deinit(); -out_free_5: +out_free_4: for_each_possible_cpu(cpu) free_cpumask_var(per_cpu(cpu_kick_mask, cpu)); -out_free_4: kmem_cache_destroy(kvm_vcpu_cache); out_free_3: unregister_reboot_notifier(&kvm_reboot_notifier); |