From: Ian Campbell Subject: Re: [PATCH 02/12] xen: events: do not leak IRQ from xen_allocate_pirq_msi when no pirq available. Date: Mon, 21 Feb 2011 13:40:00 +0000 Message-ID: <1298295600.16356.7804.camel@zakaz.uk.xensource.com> References: <1298047386.16356.3620.camel@zakaz.uk.xensource.com> <1298047417-7445-2-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: Jeremy Fitzhardinge , "xen-devel@lists.xensource.com" , Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org On Mon, 2011-02-21 at 12:50 +0000, Stefano Stabellini wrote: > On Fri, 18 Feb 2011, Ian Campbell wrote: > > Signed-off-by: Ian Campbell > > Cc: Jeremy Fitzhardinge > > Cc: Konrad Rzeszutek Wilk > > Cc: xen-devel@lists.xensource.com > > --- > > drivers/xen/events.c | 5 ++++- > > 1 files changed, 4 insertions(+), 1 deletions(-) > > > > diff --git a/drivers/xen/events.c b/drivers/xen/events.c > > index c536157..41a8a65 100644 > > --- a/drivers/xen/events.c > > +++ b/drivers/xen/events.c > > @@ -666,8 +666,11 @@ void xen_allocate_pirq_msi(char *name, int *irq, int *pirq, int alloc) > > > > if (alloc & XEN_ALLOC_PIRQ) { > > *pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI); > > - if (*pirq == -1) > > + if (*pirq == -1) { > > + xen_free_irq(*irq); > > + *irq = -1; > > goto out; > > + } > > } > > > > set_irq_chip_and_handler_name(*irq, &xen_pirq_chip, > > What if the caller didn't pass XEN_ALLOC_IRQ? > *irq could contain garbage here. > Considering that later on you are removing XEN_ALLOC_IRQ altogether, > maybe you just need to move this patch afterwards. good idea.