2023-01-27 02:53:04

by Jarkko Sakkinen

[permalink] [raw]
Subject: [PATCH RFC 2/8] KVM: SVM: fix: initialize `npinned`

From: Tom Dohrmann <[email protected]>

If UPM is enabled and getting the PFN fails, `npinned` is never set, but is
read for the call to `unpin_user_pages`.

Link: https://lore.kernel.org/lkml/Y6Sgwp%2FBofzCUrQe@notebook/
Signed-off-by: Tom Dohrmann <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
---
arch/x86/kvm/svm/sev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index d3468d1533bd..6d3162853c33 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -510,7 +510,7 @@ static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr,
{
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
unsigned long npages, size;
- int npinned;
+ int npinned = 0;
unsigned long locked, lock_limit;
struct page **pages;
unsigned long first, last;
--
2.38.1