• Prarit Bhargava's avatar
    PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs · 81efbadd
    Prarit Bhargava authored
    During device setup, msix_setup_entries() and msi_setup_entry() allocate
    msi_desc by calling alloc_msi_entry().  alloc_msi_entry() can also allocate
    a affinity cpumask.  During device teardown free_msi_irqs() is called and
    the msi_desc is freed, but the affinity cpumask is leaked.
    
    Fix it by calling free_msi_entry() which frees both the msi_desc and the
    affinity cpumask.
    
    [bhelgaas: aa48b6f7 ("genirq/MSI: Move alloc_msi_entry() from PCI into
     generic MSI code") moved alloc_msi_entry() from drivers/pci/msi.c to
     kernel/irq/msi.c and added a new corresponding free_msi_entry() interface.
    
     After aa48b6f7, pci/msi.c used alloc_msi_entry(), but did its own
     kfree() instead of using free_msi_entry().  28f4b041 ("genirq/msi: Add
     cpumask allocation to alloc_msi_entry") added affinity to both
     alloc_msi_entry() and free_msi_entry(), but pci/msi.c didn't use
     free_msi_entry(), resulting in this leak.]
    
    Fixes: aa48b6f7 ("genirq/MSI: Move alloc_msi_entry() from PCI into generic MSI code")
    Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    CC: Myron Stowe <mstowe@redhat.com>
    81efbadd
msi.c 37.9 KB