]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: endpoint: Fix configfs group removal on driver teardown
authorDamien Le Moal <dlemoal@kernel.org>
Tue, 24 Jun 2025 11:45:44 +0000 (20:45 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:21:31 +0000 (16:21 +0200)
commit 910bdb8197f9322790c738bb32feaa11dba26909 upstream.

An endpoint driver configfs attributes group is added to the
epf_group list of struct pci_epf_driver by pci_epf_add_cfs() but an
added group is not removed from this list when the attribute group is
unregistered with pci_ep_cfs_remove_epf_group().

Add the missing list_del() call in pci_ep_cfs_remove_epf_group()
to correctly remove the attribute group from the driver list.

With this change, once the loop over all attribute groups in
pci_epf_remove_cfs() completes, the driver epf_group list should be
empty. Add a WARN_ON() to make sure of that.

Fixes: ef1433f717a2 ("PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250624114544.342159-3-dlemoal@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/endpoint/pci-ep-cfs.c
drivers/pci/endpoint/pci-epf-core.c

index d1288a0bd53041bf8439671af9d6a7f5611b3e7f..98d54c78f08d8acdacdac4587baed02e5479363a 100644 (file)
@@ -480,6 +480,7 @@ void pci_ep_cfs_remove_epf_group(struct config_group *group)
        if (IS_ERR_OR_NULL(group))
                return;
 
+       list_del(&group->group_entry);
        configfs_unregister_default_group(group);
 }
 EXPORT_SYMBOL(pci_ep_cfs_remove_epf_group);
index 71372cef1a68e0098602fe45e2994e1b2fab64e2..3d76bebe96c1ce3896911b4f024c5de844005c16 100644 (file)
@@ -155,6 +155,7 @@ static void pci_epf_remove_cfs(struct pci_epf_driver *driver)
        mutex_lock(&pci_epf_mutex);
        list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry)
                pci_ep_cfs_remove_epf_group(group);
+       WARN_ON(!list_empty(&driver->epf_group));
        mutex_unlock(&pci_epf_mutex);
 }