]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86/xen: Simplify eventfd IOCTLs
authorMichal Luczaj <mhal@rbox.co>
Thu, 22 Dec 2022 20:30:21 +0000 (21:30 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 24 Dec 2022 08:54:13 +0000 (03:54 -0500)
Port number is validated in kvm_xen_setattr_evtchn().
Remove superfluous checks in kvm_xen_eventfd_assign() and
kvm_xen_eventfd_update().

Signed-off-by: Michal Luczaj <mhal@rbox.co>
Message-Id: <20221222203021.1944101-3-mhal@rbox.co>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/xen.c

index 935f845d005cac2935e5556c73403f8c2044b264..61327b4e7a14c7b54fb67e1ee363d7a6f3114a6d 100644 (file)
@@ -1827,9 +1827,6 @@ 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);
@@ -1875,12 +1872,9 @@ static int kvm_xen_eventfd_assign(struct kvm *kvm,
 {
        u32 port = data->u.evtchn.send_port;
        struct eventfd_ctx *eventfd = NULL;
-       struct evtchnfd *evtchnfd = NULL;
+       struct evtchnfd *evtchnfd;
        int ret = -EINVAL;
 
-       if (!port || port >= max_evtchn_port(kvm))
-               return -EINVAL;
-
        evtchnfd = kzalloc(sizeof(struct evtchnfd), GFP_KERNEL);
        if (!evtchnfd)
                return -ENOMEM;