Re: [PATCH 086/190] Revert "x86/PCI: Fix PCI IRQ routing table memory leak"

From: Greg Kroah-Hartman
Date: Mon Apr 26 2021 - 12:54:15 EST


On Fri, Apr 23, 2021 at 11:53:31AM +0200, Thomas Gleixner wrote:
> On Thu, Apr 22 2021 at 00:09, Bjorn Helgaas wrote:
> > On Wed, Apr 21, 2021 at 02:59:21PM +0200, Greg Kroah-Hartman wrote:
> > I would prefer that you not apply this revert.
> >
> > Prior to ea094d53580f ("x86/PCI: Fix PCI IRQ routing table memory
> > leak"), we had essentially this:
> >
> > pcibios_irq_init()
> > pirq_table = pcibios_get_irq_routing_table(); # kmallocs
> > if (pirq_table) {
> > if (io_apic_assign_pci_irqs)
> > pirq_table = NULL;
> > }
> >
> > So if we called pcibios_get_irq_routing_table(), we kmalloced some
> > space and then (if io_apic_assign_pci_irqs) threw away the pointer,
> > which leaks the pointer as the commit log says.
> >
> > After ea094d53580f, we have:
> >
> > pcibios_irq_init()
> > rtable = NULL;
> > pirq_table = pcibios_get_irq_routing_table(); # kmallocs
> > rtable = pirq_table;
> > if (pirq_table) {
> > if (io_apic_assign_pci_irqs) {
> > kfree(rtable);
> > pirq_table = NULL;
> > }
> > }
> >
> > which seems right to me.
>
> It is correct.

Thanks for the review, I'll go drop this revert.

greg k-h