linux-stable/kernel/irq
Jason Gunthorpe ac8f29aef2 genirq/msi: Free the fwnode created by msi_create_device_irq_domain()
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: 27a6dea3eb ("genirq/msi: Provide msi_create/free_device_irq_domain()")
Reported-by: Omri Barazi <obarazi@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Kalle Valo <kvalo@kernel.org>
Tested-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/0-v2-24af6665e2da+c9-msi_leak_jgg@nvidia.com
2023-01-17 22:57:04 +01:00
..
Kconfig genirq: Get rid of GENERIC_MSI_IRQ_DOMAIN 2022-11-17 15:15:20 +01:00
Makefile genirq/timings: Add selftest for circular array 2019-06-12 10:47:04 +02:00
affinity.c irqchip updates for 5.19: 2022-05-20 18:48:54 +02:00
autoprobe.c genirq: Delay deactivation in free_irq() 2019-07-03 10:12:28 +02:00
chip.c genirq/irqdomain: Rename irq_domain::dev to irq_domain:: Pm_dev 2022-12-05 19:20:58 +01:00
cpuhotplug.c sched/isolation: Use single feature type while referring to housekeeping cpumask 2022-02-16 15:57:55 +01:00
debug.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk 2018-02-01 13:36:15 -08:00
debugfs.c genirq: Return a const cpumask from irq_data_get_affinity_mask 2022-07-07 09:38:04 +01:00
devres.c genirq/devres: Use struct_size() in devm_kzalloc() 2019-04-16 21:54:03 +02:00
dummychip.c irq: Fix typos in comments 2021-03-22 04:23:14 +01:00
generic-chip.c genirq/generic_chip: Export irq_unmap_generic_chip 2022-07-20 12:05:55 +01:00
handle.c irq: remove unused flags argument from __handle_irq_event_percpu() 2022-01-07 00:25:25 +01:00
internals.h genirq/irqdesc: Don't try to remove non-existing sysfs files 2022-11-30 14:52:11 +01:00
ipi.c genirq: Return a const cpumask from irq_data_get_affinity_mask 2022-07-07 09:38:04 +01:00
irq_sim.c genirq/irq_sim: Make the irq_work always run in hard irq context 2022-05-14 17:48:27 +02:00
irqdesc.c genirq/irqdesc: Don't try to remove non-existing sysfs files 2022-11-30 14:52:11 +01:00
irqdomain.c genirq/msi: Free the fwnode created by msi_create_device_irq_domain() 2023-01-17 22:57:04 +01:00
manage.c genirq: Remove unused argument force of irq_set_affinity_deactivated() 2022-11-17 14:00:55 +01:00
matrix.c genirq/matrix: Remove redundant assignment to variable 'end' 2022-04-25 15:02:57 +02:00
migration.c genirq: Fix typos and misspellings in comments 2021-03-16 15:08:29 +01:00
msi.c genirq/msi: Free the fwnode created by msi_create_device_irq_domain() 2023-01-17 22:57:04 +01:00
pm.c genirq/PM: Unexport {suspend,resume}_device_irqs() 2022-06-13 12:27:37 +02:00
proc.c proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
resend.c genirq: Fix typos and misspellings in comments 2021-03-16 15:08:29 +01:00
settings.h genirq: Add a IRQF_NO_DEBUG flag 2021-05-17 20:01:35 +02:00
spurious.c genirq: Disable irqfixup/poll on PREEMPT_RT. 2021-09-19 23:01:15 +02:00
timings.c Updates to the interrupt core and driver subsystems: 2021-08-30 14:38:37 -07:00