Re: [PATCH -tip/master] x86: io-apic - interrupt remapping fix

From: Suresh Siddha
Date: Tue Sep 23 2008 - 14:34:23 EST


On Mon, Sep 22, 2008 at 09:56:37PM -0700, Cyrill Gorcunov wrote:
> [Suresh Siddha - Mon, Sep 22, 2008 at 06:16:21PM -0700]
> | On Mon, Sep 22, 2008 at 05:57:38PM -0700, Siddha, Suresh B wrote:
> | > On Fri, Sep 19, 2008 at 05:33:20AM -0700, Cyrill Gorcunov wrote:
> | > > Interrupt remapping could lead to NULL dereference in case of
> | > > kzalloc failed and memory leak in other way. So fix the
> | > > both cases.
> | > >
> | > > Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
> | > > ---
> | > >
> | > > Ingo, the patch is on top of applied one.
> | > >
> | > > If I remember correctly Suresh was involved in
> | > > this - so I think he could take a look and review
> | > > the patch (please).
> | > >
> | >
> | > Acked-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
> |
> | oops. Cyrill some typo here:
> |
> | + for (; apic > 0; apic--)
> | + kfree(early_ioapic_entries[apic]);
> | + kfree(early_ioapic_entries[apic]);
> |
>
> Hi Suresh, thanks for review!
>
> Well it's not typo actually :) Of course it could
> be like
>
> for (--apic; apic > 0; apic--)
> or
> for (apic--; apic > 0; apic--)
>
> but it will be a rpoblem in case if apic = 0 and
> if someday apic would be unsigned int. So I prefered
> to have _one_ kfree(NULL) call instead :)
>
> I hope i didn't miss anything.

This is too confusing. Please change it to something simple, like:

for (i = 0; i < apic; i++)
kfree(early_ioapic_entries[i]);

or

for (apic = 0; apic < nr_ioapics; apic++)
kfree(early_ioapic_entries[apic]);

thanks,
suresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/