kvm: fix usage of uninit spinlock in avic_vm_destroy()
authorDmitry Vyukov <dvyukov@google.com>
Tue, 24 Jan 2017 13:06:48 +0000 (14:06 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Dec 2017 13:23:36 +0000 (14:23 +0100)
commit2a7eee3d72b043d68af4098665eee89893386445
tree82a59c8392cacd63fd049d03063624910bb92412
parent2d9a34c064ad3f4296b5a00e29a75a4280e797c0
kvm: fix usage of uninit spinlock in avic_vm_destroy()

[ Upstream commit 3863dff0c3dd72984395c93b12383b393c5c3989 ]

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>
arch/x86/kvm/svm.c