Skip to content

Commit fb454ba

Browse files
damien-lemoalgregkh
authored andcommitted
PCI: endpoint: Fix configfs group removal on driver teardown
commit 910bdb8 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: ef1433f ("PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry") Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dc4ffbd commit fb454ba

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

drivers/pci/endpoint/pci-ep-cfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ void pci_ep_cfs_remove_epf_group(struct config_group *group)
658658
if (IS_ERR_OR_NULL(group))
659659
return;
660660

661+
list_del(&group->group_entry);
661662
configfs_unregister_default_group(group);
662663
}
663664
EXPORT_SYMBOL(pci_ep_cfs_remove_epf_group);

drivers/pci/endpoint/pci-epf-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ static void pci_epf_remove_cfs(struct pci_epf_driver *driver)
343343
mutex_lock(&pci_epf_mutex);
344344
list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry)
345345
pci_ep_cfs_remove_epf_group(group);
346+
WARN_ON(!list_empty(&driver->epf_group));
346347
mutex_unlock(&pci_epf_mutex);
347348
}
348349

0 commit comments

Comments
 (0)