linux-stable/drivers/pci
Sascha Hauer a5866d531b 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-18 11:41:49 +01:00
..
controller PCI: tegra194: Fix link up retry sequence 2022-08-25 11:17:58 +02:00
endpoint
hotplug PCI: pciehp: Add Qualcomm quirk for Command Completed erratum 2022-04-15 14:18:33 +02:00
pcie
switch
access.c PCI: Reduce warnings on possible RW1C corruption 2022-04-15 14:18:15 +02:00
ats.c
bus.c
ecam.c
host-bridge.c
iov.c
irq.c PCI: Check for alloc failure in pci_request_irq() 2023-01-18 11:41:18 +01:00
Kconfig
Makefile
mmap.c
msi.c PCI/MSI: Fix pci_irq_vector()/pci_irq_get_affinity() 2022-01-27 09:19:38 +01:00
of.c
p2pdma.c
pci-acpi.c
pci-bridge-emul.c PCI: pci-bridge-emul: Set PCI_STATUS_CAP_LIST for PCIe device 2022-01-27 09:19:50 +01:00
pci-bridge-emul.h
pci-driver.c
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c PCI/sysfs: Fix double free in error path 2023-01-18 11:41:49 +01:00
pci.c PCI: Fix pci_device_is_present() for VFs by checking PF 2023-01-18 11:41:49 +01:00
pci.h
probe.c
proc.c
quirks.c PCI: Add ACS quirk for Broadcom BCM5750x NICs 2022-08-25 11:18:31 +02: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-26 13:22:16 +02:00
slot.c
syscall.c
vc.c
vpd.c
xen-pcifront.c