linux-stable/drivers/pci
Sascha Hauer 1c2417ace3 PCI/sysfs: Fix double free in error path
commit aa382ffa70 upstream.

When pci_create_attr() fails, pci_remove_resource_files() is called which
will iterate over the res_attr[_wc] arrays and frees every non NULL entry.
To avoid a double free here set the array entry only after it's clear we
successfully initialized it.

Fixes: b562ec8f74 ("PCI: Don't leak memory if sysfs_create_bin_file() fails")
Link: https://lore.kernel.org/r/20221007070735.GX986@pengutronix.de/
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-07 11:15:56 +01:00
..
controller PCI: vmd: Fix secondary bus reset for Intel bridges 2022-12-31 13:26:22 +01:00
endpoint PCI: endpoint: pci-epf-vntb: Fix call pci_epc_mem_free_addr() in error path 2022-12-31 13:26:20 +01:00
hotplug PCI: hotplug: Clean up include files 2022-04-05 11:13:33 -05:00
msi
pcie Merge branch 'pci/err' 2022-08-04 11:41:52 -05:00
switch PCI: switchtec: Prefer ida_alloc()/free() over ida_simple_get()/remove() 2022-06-09 12:28:21 -05:00
Kconfig cxl for 6.0 2022-08-10 11:07:26 -07:00
Makefile PCI/DOE: Add DOE mailbox support functions 2022-07-19 15:38:04 -07:00
access.c
ats.c
bus.c
doe.c PCI/DOE: Fix maximum data object length miscalculation 2023-01-07 11:15:49 +01:00
ecam.c
host-bridge.c
iov.c
irq.c PCI: Check for alloc failure in pci_request_irq() 2022-12-31 13:26:19 +01:00
mmap.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
of.c IOMMU Updates for Linux v5.19 2022-05-31 09:56:54 -07:00
p2pdma.c PCI/P2PDMA: Remove pci_p2pdma_[un]map_sg() 2022-07-26 07:28:08 -04:00
pci-acpi.c PCI/ACPI: Update link to PCI firmware specification 2022-07-22 14:38:38 -05:00
pci-bridge-emul.c Merge branch 'remotes/lorenzo/pci/mvebu' 2022-03-22 17:16:25 -05:00
pci-bridge-emul.h
pci-driver.c IOMMU Updates for Linux v5.19 2022-05-31 09:56:54 -07:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c PCI: pci_stub: Set driver_managed_dma 2022-04-28 15:32:20 +02:00
pci-sysfs.c PCI/sysfs: Fix double free in error path 2023-01-07 11:15:56 +01:00
pci.c PCI: Fix pci_device_is_present() for VFs by checking PF 2023-01-07 11:15:56 +01:00
pci.h PCI/ASPM: Remove pcie_aspm_pm_state_change() 2022-07-12 10:08:26 -05:00
probe.c Revert "PCI: Clear PCI_STATUS when setting up device" 2022-12-31 13:26:47 +01:00
proc.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
quirks.c Merge branch 'pci/header-cleanup-immutable' 2022-08-04 11:46:53 -05:00
remove.c
rom.c
search.c
setup-bus.c
setup-irq.c
setup-res.c PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge 2022-10-21 12:37:43 +02:00
slot.c
syscall.c
vc.c
vgaarb.c
vpd.c
xen-pcifront.c xen/pcifront: use xenbus_setup_ring() and xenbus_teardown_ring() 2022-05-19 14:22:02 +02:00