]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: x86/xen: Fix cleanup logic in emulation of Xen schedop poll hypercalls
authorManuel Andreas <manuel.andreas@tum.de>
Wed, 23 Jul 2025 15:51:20 +0000 (17:51 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 23 Jul 2025 21:48:54 +0000 (23:48 +0200)
kvm_xen_schedop_poll does a kmalloc_array() when a VM polls the host
for more than one event channel potr (nr_ports > 1).

After the kmalloc_array(), the error paths need to go through the
"out" label, but the call to kvm_read_guest_virt() does not.

Fixes: 92c58965e965 ("KVM: x86/xen: Use kvm_read_guest_virt() instead of open-coding it badly")
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Manuel Andreas <manuel.andreas@tum.de>
[Adjusted commit message. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/xen.c

index 5fa2cca436534bfd44df1730b9115b1d8a0a5a3a..d6b2a665b499dcdc533aa52fad6a47c5efeb77e0 100644 (file)
@@ -1526,7 +1526,7 @@ static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcpu, bool longmode,
        if (kvm_read_guest_virt(vcpu, (gva_t)sched_poll.ports, ports,
                                sched_poll.nr_ports * sizeof(*ports), &e)) {
                *r = -EFAULT;
-               return true;
+               goto out;
        }
 
        for (i = 0; i < sched_poll.nr_ports; i++) {