Skip to content

Commit 2a7eee3

Browse files
dvyukovgregkh
authored andcommitted
kvm: fix usage of uninit spinlock in avic_vm_destroy()
[ Upstream commit 3863dff ] If avic is not enabled, avic_vm_init() does nothing and returns early. However, avic_vm_destroy() still tries to destroy what hasn't been created. The only bad consequence of this now is that avic_vm_destroy() uses svm_vm_data_hash_lock that hasn't been initialized (and is not meant to be used at all if avic is not enabled). Return early from avic_vm_destroy() if avic is not enabled. It has nothing to destroy. Signed-off-by: Dmitry Vyukov <dvyukov@google.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: kvm@vger.kernel.org Cc: syzkaller@googlegroups.com Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2d9a34c commit 2a7eee3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/x86/kvm/svm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,9 @@ static void avic_vm_destroy(struct kvm *kvm)
13821382
unsigned long flags;
13831383
struct kvm_arch *vm_data = &kvm->arch;
13841384

1385+
if (!avic)
1386+
return;
1387+
13851388
avic_free_vm_id(vm_data->avic_vm_id);
13861389

13871390
if (vm_data->avic_logical_id_table_page)

0 commit comments

Comments
 (0)