linux-stable/drivers/pci
Sascha Hauer b33528863d 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:11:53 +01:00
..
controller PCI: vmd: Fix secondary bus reset for Intel bridges 2022-12-31 13:32:36 +01:00
endpoint PCI: endpoint: pci-epf-vntb: Fix call pci_epc_mem_free_addr() in error path 2022-12-31 13:32:34 +01:00
hotplug PCI: hotplug: Clean up include files 2022-04-05 11:13:33 -05:00
msi PCI/MSI: Correct 'can_mask' test in msi_add_msi_desc() 2022-08-26 10:47:54 -05:00
pcie Merge branch 'pci/pm' 2022-10-05 17:32:53 -05:00
switch PCI: switchtec: Prefer ida_alloc()/free() over ida_simple_get()/remove() 2022-06-09 12:28:21 -05:00
access.c PCI: Reduce warnings on possible RW1C corruption 2022-03-04 15:59:52 -06:00
ats.c
bus.c
doe.c PCI/DOE: Fix maximum data object length miscalculation 2023-01-07 11:11:46 +01:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Fix wrong kernel-doc identifier 2022-03-07 12:06:10 -07:00
irq.c PCI: Check for alloc failure in pci_request_irq() 2022-12-31 13:32:33 +01: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
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: Use for_each_pci_dev() helper 2022-09-19 13:44:38 -05:00
pci-acpi.c PCI/ACPI: Update link to PCI firmware specification 2022-07-22 14:38:38 -05:00
pci-bridge-emul.c PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-bridge-emul.h PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-08-25 12:07:56 +02:00
pci-driver.c PCI/PM: Simplify pci_pm_suspend_noirq() 2022-09-12 15:30:18 -05: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:11:53 +01:00
pci.c PCI: Fix pci_device_is_present() for VFs by checking PF 2023-01-07 11:11:53 +01:00
pci.h Merge branch 'remotes/lorenzo/pci/misc' 2022-10-05 17:32:57 -05:00
probe.c Revert "PCI: Clear PCI_STATUS when setting up device" 2022-12-31 13:33:05 +01:00
proc.c PCI: Remove pci_mmap_page_range() wrapper 2022-07-29 12:08:44 -05:00
quirks.c PCI/DPC: Quirk PIO log size for certain Intel Root Ports 2022-09-27 18:13:18 -05:00
remove.c
rom.c
search.c
setup-bus.c Revert "PCI: Distribute available resources for root buses, too" 2022-10-14 14:27:58 -05:00
setup-irq.c
setup-res.c PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge 2022-09-21 17:52:47 -05:00
slot.c
syscall.c
vc.c
vgaarb.c PCI/VGA: Replace full MIT license text with SPDX identifier 2022-03-09 18:31:34 -06:00
vpd.c
xen-pcifront.c xen/pcifront: move xenstore config scanning into sub-function 2022-10-07 07:36:44 +02:00