[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250723111124.13694-1-manivannan.sadhasivam@oss.qualcomm.com>
Date: Wed, 23 Jul 2025 16:41:24 +0530
From: Manivannan Sadhasivam <manivannan.sadhasivam@....qualcomm.com>
To: bhelgaas@...gle.com
Cc: linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Manivannan Sadhasivam <manivannan.sadhasivam@....qualcomm.com>,
Shuan He <heshuan@...edance.com>
Subject: [PATCH] PCI: Remove redudant calls to pci_create_sysfs_dev_files() and pci_proc_attach_device()
Both pci_create_sysfs_dev_files() and pci_proc_attach_device() are called
from pci_bus_add_device(). Calling these APIs from other places is prone to
a race condition as nothing prevents the callers from racing against
each other.
Moreover, the proper place to create SYSFS and PROCFS entries is during
the 'pci_dev' creation. So there is no real need to call these APIs
elsewhere.
Hence, remove the calls from pci_sysfs_init() and pci_proc_init().
Reported-by: Shuan He <heshuan@...edance.com>
Closes: https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@....qualcomm.com>
---
drivers/pci/pci-sysfs.c | 9 ---------
drivers/pci/proc.c | 3 ---
2 files changed, 12 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 268c69daa4d5..8e712c14e6ea 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1676,18 +1676,9 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
static int __init pci_sysfs_init(void)
{
- struct pci_dev *pdev = NULL;
struct pci_bus *pbus = NULL;
- int retval;
sysfs_initialized = 1;
- for_each_pci_dev(pdev) {
- retval = pci_create_sysfs_dev_files(pdev);
- if (retval) {
- pci_dev_put(pdev);
- return retval;
- }
- }
while ((pbus = pci_find_next_bus(pbus)))
pci_create_legacy_files(pbus);
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 9348a0fb8084..b78286afe18e 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -463,13 +463,10 @@ int pci_proc_detach_bus(struct pci_bus *bus)
static int __init pci_proc_init(void)
{
- struct pci_dev *dev = NULL;
proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
proc_create_seq("devices", 0, proc_bus_pci_dir,
&proc_bus_pci_devices_op);
proc_initialized = 1;
- for_each_pci_dev(dev)
- pci_proc_attach_device(dev);
return 0;
}
--
2.45.2
Powered by blists - more mailing lists