From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 1/2] xen: close evtchn port if binding to irq fails Date: Tue, 19 Feb 2013 09:54:19 -0500 Message-ID: <20130219145416.GH7026@konrad-lan.dumpdata.com> References: <1361199479-26059-1-git-send-email-wei.liu2@citrix.com> <1361199479-26059-2-git-send-email-wei.liu2@citrix.com> <20130219143225.GA7026@konrad-lan.dumpdata.com> <1361285191.2937.6.camel@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1361285191.2937.6.camel@zion.uk.xensource.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: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Tue, Feb 19, 2013 at 02:46:31PM +0000, Wei Liu wrote: > On Tue, 2013-02-19 at 14:32 +0000, Konrad Rzeszutek Wilk wrote: > > On Mon, Feb 18, 2013 at 02:57:58PM +0000, Wei Liu wrote: > > > Signed-off-by: Wei Liu > > > > I thought we had discussed doing this check in the user of > > this as well? > > > > Hah? I remember Jan's comment on the port == 0 case and your suggestion > to add BUG_ON() in the unbind path. Did I miss anything? This patch by itself is fine. I thought that we had chatted of adding a check in evtchn_bind_to_user to check the return value and so something about it. But the more I think about this - it makes less sense than doing it here. So this patch is good - putting it on my 3.9 list. > > > Wei. > > > > --- > > > drivers/xen/evtchn.c | 10 ++++++++++ > > > 1 file changed, 10 insertions(+) > > > > > > diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c > > > index b1f60a0..b2db77e 100644 > > > --- a/drivers/xen/evtchn.c > > > +++ b/drivers/xen/evtchn.c > > > @@ -269,6 +269,14 @@ static int evtchn_bind_to_user(struct per_user_data *u, int port) > > > u->name, (void *)(unsigned long)port); > > > if (rc >= 0) > > > rc = evtchn_make_refcounted(port); > > > + else { > > > + /* bind failed, should close the port now */ > > > + struct evtchn_close close; > > > + close.port = port; > > > + if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0) > > > + BUG(); > > > + set_port_user(port, NULL); > > > + } > > > > > > return rc; > > > } > > > @@ -277,6 +285,8 @@ static void evtchn_unbind_from_user(struct per_user_data *u, int port) > > > { > > > int irq = irq_from_evtchn(port); > > > > > > + BUG_ON(irq < 0); > > > + > > > unbind_from_irqhandler(irq, (void *)(unsigned long)port); > > > > > > set_port_user(port, NULL); > > > -- > > > 1.7.10.4 > > > > >