summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--virt/kvm/kvm_main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b2c8d429442d..a483da96f4be 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2834,8 +2834,7 @@ static kvm_pfn_t kvm_resolve_pfn(struct kvm_follow_pfn *kfp, struct page *page,
pfn = page_to_pfn(page);
}
- if (kfp->refcounted_page)
- *kfp->refcounted_page = page;
+ *kfp->refcounted_page = page;
return pfn;
}
@@ -2986,6 +2985,9 @@ kvm_pfn_t hva_to_pfn(struct kvm_follow_pfn *kfp)
might_sleep();
+ if (WARN_ON_ONCE(!kfp->refcounted_page))
+ return KVM_PFN_ERR_FAULT;
+
if (hva_to_pfn_fast(kfp, &pfn))
return pfn;