From 1d7d5d3f138f9048d0cf8e63f94419e48d660f75 Mon Sep 17 00:00:00 2001 From: Old-Ding <35417409+Old-Ding@users.noreply.github.com> Date: Mon, 6 Jul 2026 05:14:50 +0800 Subject: [PATCH] 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 <35417409+Old-Ding@users.noreply.github.com> --- 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; }