This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch releases/13.0
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/13.0 by this push:
new 1d7d5d3f138 drivers: pci: Fix EPC MSI IRQ map validation
1d7d5d3f138 is described below
commit 1d7d5d3f138f9048d0cf8e63f94419e48d660f75
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;
}