linux/drivers/pci
Bartosz Golaszewski 1d59d474e1 PCI: Hold rescan lock while adding devices during host probe
Since adding the PCI power control code, we may end up with a race between
the pwrctl platform device rescanning the bus and host controller probe
functions. The latter need to take the rescan lock when adding devices or
we may end up in an undefined state having two incompletely added devices
and hit the following crash when trying to remove the device over sysfs:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
  Internal error: Oops: 0000000096000004 [#1] SMP
  Call trace:
    __pi_strlen+0x14/0x150
    kernfs_find_ns+0x80/0x13c
    kernfs_remove_by_name_ns+0x54/0xf0
    sysfs_remove_bin_file+0x24/0x34
    pci_remove_resource_files+0x3c/0x84
    pci_remove_sysfs_dev_files+0x28/0x38
    pci_stop_bus_device+0x8c/0xd8
    pci_stop_bus_device+0x40/0xd8
    pci_stop_and_remove_bus_device_locked+0x28/0x48
    remove_store+0x70/0xb0
    dev_attr_store+0x20/0x38
    sysfs_kf_write+0x58/0x78
    kernfs_fop_write_iter+0xe8/0x184
    vfs_write+0x2dc/0x308
    ksys_write+0x7c/0xec

Fixes: 4565d2652a ("PCI/pwrctl: Add PCI power control core code")
Link: https://lore.kernel.org/r/20241003084342.27501-1-brgl@bgdev.pl
Reported-by: Konrad Dybcio <konradybcio@kernel.org>
Tested-by: Konrad Dybcio <konradybcio@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2024-10-12 09:31:44 -05:00
..
controller pci-v6.12-changes 2024-09-23 12:47:06 -07:00
endpoint PCI: Pass domain number to pci_bus_release_domain_nr() explicitly 2024-09-13 22:12:29 +00:00
hotplug pci-v6.12-changes 2024-09-23 12:47:06 -07:00
msi Switch ARM/ARM64 over to the modern per device MSI domains: 2024-07-22 14:02:19 -07:00
pcie PCI/AER: Use PCI_DEVID() macro in aer_inject() 2024-09-01 17:05:45 +00:00
pwrctl pci-v6.12-changes 2024-09-23 12:47:06 -07:00
switch PCI: switchtec: Make switchtec_class constant 2024-06-10 15:03:30 -05:00
access.c PCI: Revert the cfg_access_lock lockdep mechanism 2024-06-04 12:10:05 -05:00
ats.c pci-v6.12-changes 2024-09-23 12:47:06 -07:00
bus.c pci-v6.11-changes 2024-07-19 19:03:18 -07:00
devres.c pci-v6.12-changes 2024-09-23 12:47:06 -07:00
doe.c PCI/DOE: Support discovery version 2 2024-04-09 09:33:15 -05:00
ecam.c
host-bridge.c
iomap.c PCI: Fix typos 2024-09-19 14:24:00 -05:00
iov.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
irq.c PCI: Place interrupt related code into irq.c 2024-01-29 17:01:31 -06:00
Kconfig PCI/NPEM: Add Native PCIe Enclosure Management support 2024-09-04 17:25:12 -05:00
Makefile PCI/NPEM: Add Native PCIe Enclosure Management support 2024-09-04 17:25:12 -05:00
mmap.c PCI/sysfs: Compile pci-sysfs.c only if CONFIG_SYSFS=y 2024-03-05 16:08:43 -06:00
npem.c PCI/NPEM: Add _DSM PCIe SSD status LED management 2024-09-06 11:37:24 -05:00
of_property.c PCI: of_property: Add interrupt-controller property in PCI device nodes 2024-07-08 17:40:30 -06:00
of.c pci-v6.11-changes 2024-07-19 19:03:18 -07:00
p2pdma.c PCI/P2PDMA: Fix a sleeping issue in a RCU read section 2024-02-08 15:31:43 -06:00
pci-acpi.c ACPI: RISC-V: Implement PCI related functionality 2024-08-27 15:48:35 +02:00
pci-bridge-emul.c PCI: Rename CRS Completion Status to RRS 2024-09-10 19:52:30 -05:00
pci-bridge-emul.h
pci-driver.c PCI: Make pci_bus_type constant 2024-08-23 12:46:22 -05:00
pci-label.c
pci-mid.c PCI/PM: Switch to new Intel CPU model defines 2024-06-11 17:08:14 -05:00
pci-pf-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-sysfs.c s390/pci: Stop usurping pdev->dev.groups 2024-08-09 14:58:27 -05:00
pci.c pci-v6.12-changes 2024-09-23 12:47:06 -07:00
pci.h Merge branch 'pci/misc' 2024-09-19 14:25:34 -05:00
probe.c PCI: Hold rescan lock while adding devices during host probe 2024-10-12 09:31:44 -05:00
proc.c
quirks.c Merge branch 'pci/quirks' 2024-09-19 14:25:34 -05:00
remove.c pci-v6.12-changes 2024-09-23 12:47:06 -07:00
rom.c
search.c PCI: Add pci_get_base_class() helper 2023-09-28 16:49:44 -05:00
setup-bus.c PCI: Relax bridge window tail sizing rules 2024-06-12 14:51:30 -05:00
setup-res.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
slot.c
syscall.c
vc.c PCI/VC: Use FIELD_GET() 2023-10-24 16:55:45 -05:00
vgaarb.c pci-v6.7-changes 2023-11-02 14:05:18 -10:00
vpd.c
xen-pcifront.c