Commit cd2d0060 authored by Dan Carpenter's avatar Dan Carpenter Committed by Paolo Bonzini

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: dee5a47c ("KVM: SEV: Add KVM_SEV_SNP_LAUNCH_UPDATE command")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Message-ID: <20240612115040.2423290-4-dan.carpenter@linaro.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 696eb24a
...@@ -2290,9 +2290,10 @@ static int sev_gmem_post_populate(struct kvm *kvm, gfn_t gfn_start, kvm_pfn_t pf ...@@ -2290,9 +2290,10 @@ static int sev_gmem_post_populate(struct kvm *kvm, gfn_t gfn_start, kvm_pfn_t pf
if (src) { if (src) {
void *vaddr = kmap_local_pfn(pfn + i); void *vaddr = kmap_local_pfn(pfn + i);
ret = copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE); if (copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE)) {
if (ret) ret = -EFAULT;
goto err; goto err;
}
kunmap_local(vaddr); kunmap_local(vaddr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment