Patch "kvm: x86: Do proper cleanup if kvm_x86_ops->vm_init() fails" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kvm: x86: Do proper cleanup if kvm_x86_ops->vm_init() fails

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-x86-do-proper-cleanup-if-kvm_x86_ops-vm_init-fai.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e1f7f2457b1342553570bfcaeadae1496f75eec1
Author: Junaid Shahid <junaids@xxxxxxxxxx>
Date:   Fri Jul 29 15:43:29 2022 -0700

    kvm: x86: Do proper cleanup if kvm_x86_ops->vm_init() fails
    
    [ Upstream commit b24ede22538b4d984cbe20532bbcb303692e7f52 ]
    
    If vm_init() fails [which can happen, for instance, if a memory
    allocation fails during avic_vm_init()], we need to cleanup some
    state in order to avoid resource leaks.
    
    Signed-off-by: Junaid Shahid <junaids@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220729224329.323378-1-junaids@xxxxxxxxxx
    Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Stable-dep-of: 5a2a961be2ad ("KVM: fix memoryleak in kvm_init()")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e2435090f225..14cb589683a1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -12103,6 +12103,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	if (ret)
 		goto out_page_track;
 
+	ret = static_call(kvm_x86_vm_init)(kvm);
+	if (ret)
+		goto out_uninit_mmu;
+
 	INIT_HLIST_HEAD(&kvm->arch.mask_notifier_list);
 	INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
 	atomic_set(&kvm->arch.noncoherent_dma_count, 0);
@@ -12138,8 +12142,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm_hv_init_vm(kvm);
 	kvm_xen_init_vm(kvm);
 
-	return static_call(kvm_x86_vm_init)(kvm);
+	return 0;
 
+out_uninit_mmu:
+	kvm_mmu_uninit_vm(kvm);
 out_page_track:
 	kvm_page_track_cleanup(kvm);
 out:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux