• Jason Gunthorpe's avatar
    genirq/msi: Free the fwnode created by msi_create_device_irq_domain() · ac8f29ae
    Jason Gunthorpe authored
    msi_create_device_irq_domain() creates a firmware node for the new domain,
    which is never freed. kmemleak reports:
    
    unreferenced object 0xffff888120ba9a00 (size 96):
      comm "systemd-modules", pid 221, jiffies 4294893411 (age 635.732s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 e0 19 8b 83 ff ff ff ff  ................
        00 00 00 00 00 00 00 00 18 9a ba 20 81 88 ff ff  ........... ....
      backtrace:
        [<000000008cdbc98d>] __irq_domain_alloc_fwnode+0x51/0x2b0
        [<00000000c57acf9d>] msi_create_device_irq_domain+0x283/0x670
        [<000000009b567982>] __pci_enable_msix_range+0x49e/0xdb0
        [<0000000077cc1445>] pci_alloc_irq_vectors_affinity+0x11f/0x1c0
        [<00000000532e9ef5>] mlx5_irq_table_create+0x24c/0x940 [mlx5_core]
        [<00000000fabd2b80>] mlx5_load+0x1fa/0x680 [mlx5_core]
        [<000000006bb22ae4>] mlx5_init_one+0x485/0x670 [mlx5_core]
        [<00000000eaa5e1ad>] probe_one+0x4c2/0x720 [mlx5_core]
        [<00000000df8efb43>] local_pci_probe+0xd6/0x170
        [<0000000085cb9924>] pci_device_probe+0x231/0x6e0
    
    Use the proper free operation for the firmware wnode so the name is freed
    during error unwind of msi_create_device_irq_domain() and also free the
    node in msi_remove_device_irq_domain() if it was automatically allocated.
    
    To avoid extra NULL pointer checks make irq_domain_free_fwnode() tolerant
    of NULL.
    
    Fixes: 27a6dea3 ("genirq/msi: Provide msi_create/free_device_irq_domain()")
    Reported-by: default avatarOmri Barazi <obarazi@nvidia.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Tested-by: default avatarKalle Valo <kvalo@kernel.org>
    Tested-by: default avatarLeon Romanovsky <leonro@nvidia.com>
    Link: https://lore.kernel.org/r/0-v2-24af6665e2da+c9-msi_leak_jgg@nvidia.com
    ac8f29ae
irqdomain.c 52.2 KB