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

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

commit 674a637c325638d67e4cb1779f62af15ba652f8d
Author: yangsong8 <[email protected]>
AuthorDate: Wed Nov 11 17:49:54 2026 +0800

    drivers/ioexpander/pl061: support both-edge interrupts and check kmm_zalloc
    
    gpio_lower_half() configures GPIO_INTERRUPT_BOTH_PIN with
    IOEXPANDER_VAL_BOTH, which pl061_option() rejected with -EINVAL, so a
    both-edge pin never got its interrupt enabled. Handle it like
    IOEXPANDER_VAL_EDGE, which already sets GPIOIBE.
    
    Also return NULL from pl061_ioe_initialize() when kmm_zalloc() fails
    instead of dereferencing the NULL pointer.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: yangsong8 <[email protected]>
---
 drivers/ioexpander/pl061.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/ioexpander/pl061.c b/drivers/ioexpander/pl061.c
index b47ff926da4..def987116af 100644
--- a/drivers/ioexpander/pl061.c
+++ b/drivers/ioexpander/pl061.c
@@ -177,7 +177,8 @@ static int pl061_option(FAR struct ioexpander_dev_s *dev, 
uint8_t pin,
             PL061_MODREG(priv, 1 << pin, 1 << pin, PL061_GPIOIE);
             break;
 
-          case IOEXPANDER_VAL_EDGE:  /* Interrupt on edge */
+          case IOEXPANDER_VAL_EDGE:    /* Interrupt on both edges */
+          case IOEXPANDER_VAL_BOTH:
             PL061_MODREG(priv, 0, 1 << pin, PL061_GPIOIS);
             PL061_MODREG(priv, 1 << pin, 1 << pin, PL061_GPIOIBE);
             PL061_MODREG(priv, 1 << pin, 1 << pin, PL061_GPIOIE);
@@ -317,6 +318,11 @@ FAR struct ioexpander_dev_s 
*pl061_ioe_initialize(uintptr_t base, int irq)
 {
   FAR struct pl061_dev_s *priv = kmm_zalloc(sizeof(struct pl061_dev_s));
 
+  if (priv == NULL)
+    {
+      return NULL;
+    }
+
   priv->dev.ops = &g_pl061_ops;
   priv->base = base;
 

Reply via email to