]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Revert "KVM: x86/xen: Simplify eventfd IOCTLs"
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 26 Dec 2022 11:24:31 +0000 (11:24 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 26 Dec 2022 11:35:15 +0000 (11:35 +0000)
This reverts commit 2727004e3dfc2fb3f756c68a1424f2a18c9ab00c.

arch/x86/kvm/xen.c

index 61327b4e7a14c7b54fb67e1ee363d7a6f3114a6d..935f845d005cac2935e5556c73403f8c2044b264 100644 (file)
@@ -1827,6 +1827,9 @@ static int kvm_xen_eventfd_update(struct kvm *kvm,
        struct evtchnfd *evtchnfd;
        int ret;
 
+       if (!port || port >= max_evtchn_port(kvm))
+               return -EINVAL;
+
        /* Protect writes to evtchnfd as well as the idr lookup.  */
        mutex_lock(&kvm->lock);
        evtchnfd = idr_find(&kvm->arch.xen.evtchn_ports, port);
@@ -1872,9 +1875,12 @@ static int kvm_xen_eventfd_assign(struct kvm *kvm,
 {
        u32 port = data->u.evtchn.send_port;
        struct eventfd_ctx *eventfd = NULL;
-       struct evtchnfd *evtchnfd;
+       struct evtchnfd *evtchnfd = NULL;
        int ret = -EINVAL;
 
+       if (!port || port >= max_evtchn_port(kvm))
+               return -EINVAL;
+
        evtchnfd = kzalloc(sizeof(struct evtchnfd), GFP_KERNEL);
        if (!evtchnfd)
                return -ENOMEM;