This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 888711ac3c9 drivers: pci: Fix EPC MSI IRQ map validation
888711ac3c9 is described below
commit 888711ac3c9c60cf6a6040a159850645ab7fb3b6
Author: Old-Ding <[email protected]>
AuthorDate: Mon Jul 6 05:14:50 2026 +0800
drivers: pci: Fix EPC MSI IRQ map validation
pci_epc_map_msi_irq() used && when checking the EPC pointer and map_msi_irq
callback. If epc is NULL, the right-hand side dereferences it; if the callback
is NULL on a valid EPC, the guard does not reject it before the call.
Match the surrounding EPC wrappers by rejecting a NULL EPC, an out-of-range
function number, or a missing map_msi_irq callback before taking the lock and
invoking the operation.
Generated-by: OpenAI Codex
Signed-off-by: Old-Ding <[email protected]>
---
drivers/pci/pci_epc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci_epc.c b/drivers/pci/pci_epc.c
index 6f487dfa8b0..8034a4be6b5 100644
--- a/drivers/pci/pci_epc.c
+++ b/drivers/pci/pci_epc.c
@@ -324,7 +324,8 @@ int pci_epc_map_msi_irq(FAR struct pci_epc_ctrl_s *epc,
uint8_t funcno,
{
int ret;
- if (epc == NULL && epc->ops->map_msi_irq == NULL)
+ if (epc == NULL || funcno >= epc->max_functions ||
+ epc->ops->map_msi_irq == NULL)
{
return -EINVAL;
}