This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1cec43cb7978f4e929d3dbcab3171720101186bd
Author: Brijesh Thakkar <[email protected]>
AuthorDate: Tue Oct 20 19:08:15 2026 +0530

    drivers/serial/uart_pci_16550: fail probe when no IRQ is available
    
    pci_u16550_initialize() stored the return value of pci_get_irq() in
    priv->common.irq without checking it.  pci_get_irq() returns a negative
    errno, e.g. -ENOTSUP when the PCI controller has no get_irq() operation,
    so the port was registered with a negative irq and the failure was only
    reported later, when the port was opened and irq_attach() failed.
    
    Check the result and fail the probe with the error instead, so the
    problem is reported where it happens.  A negative irq is meant to be an
    explicit opt-in to a polled UART for board-defined ports (see
    struct u16550_s::irq) and must not come from a PCI error.
    
    Assisted-by: Claude:claude-sonnet-5-5
    Signed-off-by: Brijesh Thakkar <[email protected]>
---
 drivers/serial/uart_pci_16550.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/uart_pci_16550.c b/drivers/serial/uart_pci_16550.c
index 7df9a272290..598440888f4 100644
--- a/drivers/serial/uart_pci_16550.c
+++ b/drivers/serial/uart_pci_16550.c
@@ -592,7 +592,14 @@ legacy_irq:
 
   /* Get legacy IRQ if MSI not supported */
 
-  priv->common.irq = pci_get_irq(dev);
+  ret = pci_get_irq(dev);
+  if (ret < 0)
+    {
+      pcierr("Failed to get legacy IRQ %d\n", ret);
+      return ret;
+    }
+
+  priv->common.irq = ret;
 
   return OK;
 }

Reply via email to