Skip to content

Commit cd2d006

Browse files
Dan Carpenterbonzini
authored andcommitted
KVM: SVM: Fix an error code in sev_gmem_post_populate()
The copy_from_user() function returns the number of bytes which it was not able to copy. Return -EFAULT instead. Fixes: dee5a47 ("KVM: SEV: Add KVM_SEV_SNP_LAUNCH_UPDATE command") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Message-ID: <20240612115040.2423290-4-dan.carpenter@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 696eb24 commit cd2d006

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,9 +2290,10 @@ static int sev_gmem_post_populate(struct kvm *kvm, gfn_t gfn_start, kvm_pfn_t pf
22902290
if (src) {
22912291
void *vaddr = kmap_local_pfn(pfn + i);
22922292

2293-
ret = copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE);
2294-
if (ret)
2293+
if (copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE)) {
2294+
ret = -EFAULT;
22952295
goto err;
2296+
}
22962297
kunmap_local(vaddr);
22972298
}
22982299

0 commit comments

Comments
 (0)