Subject: Re: [PATCH 1/2] Add irq_free_host() to free an irq_host

From: Michael Ellerman <[email-masked]>
Date: Thu, 15 May 2008 17:00:37 +1000

On Wed, 2008-05-14 at 23:55 -0700, Benjamin Herrenschmidt wrote:
> On Thu, 2008-05-08 at 14:23 +1000, Michael Ellerman wrote:
> > +void irq_free_host(struct irq_host *host)
> > +{
> > +       /* If it's still very early in boot we can't free, oh well. */
> > +       if (mem_init_done)
> > +               kfree(host);
> > +}
> 
> Hrm... that means that a host that was allocated before mem_init_done
> and freed later will call kfree on memory obtained from bootmem... no
> good.

God damn mem_init_done crap .. gah you're right.

> In which case do we need to free and irq host other than failure in
> irq_alloc_host ?

Well most code either doesn't check the return value, or panics. There's
two callers at the moment (after my patch) of irq_free_host(),
axon_msi.c and ipic.c - they both call free from the same function as
alloc so they're safe.

We could just do the free in irq_alloc_host()'s error path and have
irq_free_host() not actually free anything, just drop the reference
count. What a mess.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person