linux-brain/drivers/pci
Geert Uytterhoeven f954030137 PCI: Fix pci_register_io_range() memory leak
[ Upstream commit f6bda644fa3a7070621c3bf12cd657f69a42f170 ]

Kmemleak reports:

  unreferenced object 0xc328de40 (size 64):
    comm "kworker/1:1", pid 21, jiffies 4294938212 (age 1484.670s)
    hex dump (first 32 bytes):
      00 00 00 00 00 00 00 00 e0 d8 fc eb 00 00 00 00  ................
      00 00 10 fe 00 00 00 00 00 00 00 00 00 00 00 00  ................

  backtrace:
    [<ad758d10>] pci_register_io_range+0x3c/0x80
    [<2c7f139e>] of_pci_range_to_resource+0x48/0xc0
    [<f079ecc8>] devm_of_pci_get_host_bridge_resources.constprop.0+0x2ac/0x3ac
    [<e999753b>] devm_of_pci_bridge_init+0x60/0x1b8
    [<a895b229>] devm_pci_alloc_host_bridge+0x54/0x64
    [<e451ddb0>] rcar_pcie_probe+0x2c/0x644

In case a PCI host driver's probe is deferred, the same I/O range may be
allocated again, and be ignored, causing a memory leak.

Fix this by (a) letting logic_pio_register_range() return -EEXIST if the
passed range already exists, so pci_register_io_range() will free it, and
by (b) making pci_register_io_range() not consider -EEXIST an error
condition.

Link: https://lore.kernel.org/r/20210202100332.829047-1-geert+renesas@glider.be
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-17 17:03:44 +01:00
..
controller PCI: mediatek: Add missing of_node_put() to fix reference leak 2021-03-17 17:03:44 +01:00
endpoint PCI: endpoint: Fix for concurrent memory allocation in OB address region 2020-04-17 10:50:11 +02:00
hotplug PCI: pciehp: Fix MSI interrupt race 2020-10-01 13:17:52 +02:00
pcie PCI/ASPM: Add missing newline in sysfs 'policy' 2020-08-19 08:16:13 +02:00
switch PCI/switchtec: Fix init_completion race condition with poll_wait() 2020-04-17 10:50:02 +02:00
Kconfig pci-v5.4-changes 2019-09-23 19:16:01 -07:00
Makefile
access.c PCI: Fix pci_cfg_wait queue locking problem 2020-08-19 08:16:11 +02:00
ats.c PCI: Fix typos and whitespace errors 2019-07-09 07:24:53 -05:00
bus.c PCI: Add device even if driver attach failed 2020-08-21 13:05:20 +02:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Mark VFs as not implementing PCI_COMMAND_MEMORY 2020-10-29 09:57:54 +01:00
irq.c
mmap.c PCI: Fix typos and whitespace errors 2019-07-09 07:24:53 -05:00
msi.c PCI/MSI: Fix incorrect MSI-X masking on resume 2019-12-21 11:04:28 +01:00
of.c PCI: OF: Correct of_irq_parse_pci() documentation 2019-08-30 14:00:34 -05:00
p2pdma.c PCI/P2PDMA: Update pci_p2pdma_distance_many() documentation 2019-08-16 08:41:59 -05:00
pci-acpi.c PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-30 11:51:32 +01:00
pci-bridge-emul.c PCI: pci-bridge-emul: Fix PCIe bit conflicts 2020-06-24 17:50:15 +02:00
pci-bridge-emul.h
pci-driver.c PCI/PM: Add missing link delays required by the PCIe spec 2020-04-29 16:33:06 +02:00
pci-label.c
pci-mid.c
pci-pf-stub.c PCI: Fix typos and whitespace errors 2019-07-09 07:24:53 -05:00
pci-stub.c
pci-sysfs.c PCI: sysfs: Revert "rescan" file renames 2020-04-08 09:08:42 +02:00
pci.c PCI: Fix pci_register_io_range() memory leak 2021-03-17 17:03:44 +01:00
pci.h PCI/PM: Add missing link delays required by the PCIe spec 2020-04-29 16:33:06 +02:00
probe.c PCI: Fix pci_register_host_bridge() device_register() error handling 2020-06-24 17:50:27 +02:00
proc.c Merge branch 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2019-09-28 08:14:15 -07:00
quirks.c PCI: Add function 1 DMA alias quirk for Marvell 9215 SATA controller 2021-03-11 14:06:50 +01:00
remove.c
rom.c PCI: Use ioremap(), not phys_to_virt() for platform ROM 2020-10-01 13:17:51 +02:00
search.c PCI: Fix pci_add_dma_alias() bitmask size 2020-02-24 08:36:24 +01:00
setup-bus.c PCI: Avoid double hpmemsize MMIO window assignment 2020-10-01 13:17:19 +02:00
setup-irq.c
setup-res.c PCI: Decline to resize resources if boot config must be preserved 2021-03-04 10:26:10 +01:00
slot.c PCI: Fix pci_slot_release() NULL pointer dereference 2020-12-30 11:51:47 +01:00
syscall.c PCI: Align checking of syscall user config accessors 2021-03-04 10:26:36 +01:00
vc.c Merge branch 'pci/trivial' 2019-09-23 16:10:31 -05:00
vpd.c PCI/VPD: Prevent VPD access for Amazon's Annapurna Labs Root Port 2019-09-16 14:10:09 +01:00
xen-pcifront.c