]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: Properly check if "page" is valid in kvm_vcpu_unmap
authorKarimAllah Ahmed <karahmed@amazon.de>
Wed, 10 Jul 2019 09:13:13 +0000 (11:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:10:59 +0000 (09:10 +0200)
commit b614c6027896ff9ad6757122e84760d938cab15e upstream.

The field "page" is initialized to KVM_UNMAPPED_PAGE when it is not used
(i.e. when the memory lives outside kernel control). So this check will
always end up using kunmap even for memremap regions.

Fixes: e45adf665a53 ("KVM: Introduce a new guest mapping API")
Cc: stable@vger.kernel.org
Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c

index 2f2d24a4dd5c2e2ef18d9bbc5f2468a627af6ced..e629766f0ec87885407aba236c872463cf44fdf6 100644 (file)
@@ -1790,7 +1790,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map,
        if (!map->hva)
                return;
 
-       if (map->page)
+       if (map->page != KVM_UNMAPPED_PAGE)
                kunmap(map->page);
 #ifdef CONFIG_HAS_IOMEM
        else