This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 10117ec2b6389b0a2292cc75f72efb26119dad39 Author: Bowen Wang <[email protected]> AuthorDate: Thu Nov 26 00:47:38 2026 +0800 drivers/pci/pci_epc: remove an endpoint function from its controller pci_epc_add_epf() links the function into epc->epf through epf->epc_node, but pci_epc_remove_epf() unlinked epf->node, the function's entry in the global EPF device list. The function stayed on the controller's list after it was freed, and pci_epf_device_unregister() then unlinked epf->node a second time, dereferencing the NULL pointers the first list_delete() left behind. Unlink epf->epc_node, and only when the function was added to this controller. Signed-off-by: Bowen Wang <[email protected]> --- drivers/pci/pci_epc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci_epc.c b/drivers/pci/pci_epc.c index 532291b2a8a..b86541d7243 100644 --- a/drivers/pci/pci_epc.c +++ b/drivers/pci/pci_epc.c @@ -778,14 +778,14 @@ out: void pci_epc_remove_epf(FAR struct pci_epc_ctrl_s *epc, FAR struct pci_epf_device_s *epf) { - if (epc == NULL || epf == NULL) + if (epc == NULL || epf == NULL || epf->epc != epc) { return; } nxmutex_lock(&epc->lock); clear_bit(epf->funcno, &epc->funcno_map); - list_delete(&epf->node); + list_delete(&epf->epc_node); epf->epc = NULL; nxmutex_unlock(&epc->lock); }
