From 74c79bbc05e9bf72cc78a4611ccfbff61e0048fd Mon Sep 17 00:00:00 2001 From: Old-Ding <35417409+Old-Ding@users.noreply.github.com> Date: Mon, 6 Jul 2026 05:32:43 +0800 Subject: [PATCH] drivers: pci: Fix EPF debug assertions pci_epf_device_register() and pci_epf_unregister_driver() used || in DEBUGASSERT expressions that validate a pointer and a required field or callback. If the pointer is NULL, the right-hand side dereferences it; if the pointer is valid but the required member is NULL, the assertion passes. Require both conditions in each assertion so the debug checks match the preconditions used later in the functions. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com> --- drivers/pci/pci_epf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci_epf.c b/drivers/pci/pci_epf.c index 269a6c5e4cd..a7c92867ebc 100644 --- a/drivers/pci/pci_epf.c +++ b/drivers/pci/pci_epf.c @@ -298,7 +298,7 @@ int pci_epf_device_register(FAR struct pci_epf_device_s *epf) FAR struct pci_epc_ctrl_s *epc; int ret; - DEBUGASSERT(epf != NULL || epf->name != NULL); + DEBUGASSERT(epf != NULL && epf->name != NULL); ret = nxmutex_lock(&g_pci_epf_lock); if (ret < 0) @@ -499,7 +499,7 @@ int pci_epf_unregister_driver(FAR struct pci_epf_driver_s *drv) FAR struct pci_epf_device_s *epf; int ret; - DEBUGASSERT(drv != NULL || drv->remove != NULL); + DEBUGASSERT(drv != NULL && drv->remove != NULL); ret = nxmutex_lock(&g_pci_epf_lock); if (ret < 0)