linux/drivers/pci/endpoint
Liu Song 24a253c3aa PCI: endpoint: Avoid creating sub-groups asynchronously
commit 7c5c7d06bd upstream.

The asynchronous creation of sub-groups by a delayed work could lead to a
NULL pointer dereference when the driver directory is removed before the
work completes.

The crash can be easily reproduced with the following commands:

  # cd /sys/kernel/config/pci_ep/functions/pci_epf_test
  # for i in {1..20}; do mkdir test && rmdir test; done

  BUG: kernel NULL pointer dereference, address: 0000000000000088
  ...
  Call Trace:
   configfs_register_group+0x3d/0x190
   pci_epf_cfs_work+0x41/0x110
   process_one_work+0x18f/0x350
   worker_thread+0x25a/0x3a0

Fix this issue by using configfs_add_default_group() API which does not
have the deadlock problem as configfs_register_group() and does not require
the delayed work handler.

Fixes: e85a2d7837 ("PCI: endpoint: Add support in configfs to associate two EPCs with EPF")
Signed-off-by: Liu Song <liu.song13@zte.com.cn>
[mani: slightly reworded the description and added stable list]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@kernel.org
Link: https://patch.msgid.link/20250710143845409gLM6JdlwPhlHG9iX3F6jK@zte.com.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-02-16 10:19:46 +01:00
..
functions PCI: endpoint: pci-epf-test: Fix sleeping function being called from atomic context 2025-12-18 14:02:38 +01:00
Kconfig PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller 2025-07-24 16:51:17 -05:00
Makefile PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller 2025-07-24 16:51:17 -05:00
pci-ep-cfs.c PCI: endpoint: Avoid creating sub-groups asynchronously 2026-02-16 10:19:46 +01:00
pci-ep-msi.c PCI: endpoint: pci-ep-msi: Fix NULL vs IS_ERR() check in pci_epf_write_msi_msg() 2025-08-11 16:28:33 +05:30
pci-epc-core.c PCI: endpoint: Align pci_epc_set_msix(), pci_epc_ops::set_msix() nr_irqs encoding 2025-05-28 16:47:56 -05:00
pci-epc-mem.c PCI: endpoint: Improve pci_epc_mem_alloc_addr() 2024-10-12 17:25:54 +05:30
pci-epf-core.c Merge branch 'pci/endpoint/doorbell' 2025-07-31 16:11:45 -05:00