From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCH 03/13] xen: fix evtchn_unbind_from_user Date: Fri, 1 Feb 2013 11:15:00 +0000 Message-ID: <510BA3B4.4010104@citrix.com> References: <1359643627-29486-1-git-send-email-wei.liu2@citrix.com> <1359643627-29486-4-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1359643627-29486-4-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: "konrad.wilk@oracle.com" , Ian Campbell , "jbeulich@suse.com" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 31/01/13 14:46, Wei Liu wrote: > It is possible the port was allocated but the irq was not. Take care of this > case. I think the port should be closed when the evtchn_bind_to_user() fails otherwise the evtchn driver is leaving the event channel in an inconsistent state. David > Signed-off-by: Wei Liu > --- > drivers/xen/evtchn.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c > index b1f60a0..d2bbea1 100644 > --- a/drivers/xen/evtchn.c > +++ b/drivers/xen/evtchn.c > @@ -277,7 +277,17 @@ static void evtchn_unbind_from_user(struct per_user_data *u, int port) > { > int irq = irq_from_evtchn(port); > > - unbind_from_irqhandler(irq, (void *)(unsigned long)port); > + /* It is possible that the port was allocated but the irq was > + * not */ > + if (irq >= 0) { > + unbind_from_irqhandler(irq, (void *)(unsigned long)port); > + } else { > + struct evtchn_close close; > + close.port = port; > + if (port != 0 && /* port 0 is never used */ > + HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0) > + BUG(); > + } > > set_port_user(port, NULL); > }