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);
{
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;