mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
KVM: fix memoryleak in kvm_init()
commit5a2a961be2
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:baff59ccdc
("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>
This commit is contained in:
parent
4441a90091
commit
5588657f41
1 changed files with 2 additions and 3 deletions
|
@ -5649,7 +5649,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
|
||||||
|
|
||||||
r = kvm_async_pf_init();
|
r = kvm_async_pf_init();
|
||||||
if (r)
|
if (r)
|
||||||
goto out_free_5;
|
goto out_free_4;
|
||||||
|
|
||||||
kvm_chardev_ops.owner = module;
|
kvm_chardev_ops.owner = module;
|
||||||
kvm_vm_fops.owner = module;
|
kvm_vm_fops.owner = module;
|
||||||
|
@ -5682,10 +5682,9 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
|
||||||
kvm_vfio_ops_exit();
|
kvm_vfio_ops_exit();
|
||||||
err_vfio:
|
err_vfio:
|
||||||
kvm_async_pf_deinit();
|
kvm_async_pf_deinit();
|
||||||
out_free_5:
|
out_free_4:
|
||||||
for_each_possible_cpu(cpu)
|
for_each_possible_cpu(cpu)
|
||||||
free_cpumask_var(per_cpu(cpu_kick_mask, cpu));
|
free_cpumask_var(per_cpu(cpu_kick_mask, cpu));
|
||||||
out_free_4:
|
|
||||||
kmem_cache_destroy(kvm_vcpu_cache);
|
kmem_cache_destroy(kvm_vcpu_cache);
|
||||||
out_free_3:
|
out_free_3:
|
||||||
unregister_reboot_notifier(&kvm_reboot_notifier);
|
unregister_reboot_notifier(&kvm_reboot_notifier);
|
||||||
|
|
Loading…
Reference in a new issue