Skip to content

Commit

Permalink
KVM: x86/xen: Simplify eventfd IOCTLs
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20221226120320.1125390-4-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
mmhal authored and bonzini committed Dec 27, 2022
1 parent 70eae03 commit 1c14faa
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions arch/x86/kvm/xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,9 +1810,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);
Expand Down Expand Up @@ -1858,12 +1855,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;
Expand Down

0 comments on commit 1c14faa

Please sign in to comment.