KVM: avoid using rcu_dereference_protected
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Aug 2017 15:55:54 +0000 (17:55 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Wed, 2 Aug 2017 20:41:02 +0000 (22:41 +0200)
commit3898da947bbaf9e7fd5816e825978d360028bba2
tree5af705bb61bbc9760de0fbc3d102227f0b21fed4
parentebd28fcb55e288030abb5bca4869603b3e1f5f7c
KVM: avoid using rcu_dereference_protected

During teardown, accesses to memslots and buses are using
rcu_dereference_protected with an always-true condition because
these accesses are done outside the usual mutexes.  This
is because the last reference is gone and there cannot be any
concurrent modifications, but rcu_dereference_protected is
ugly and unobvious.

Instead, check the refcount in kvm_get_bus and __kvm_memslots.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c