This is an automated email from the ASF dual-hosted git repository.
xiaoxiang 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 e143acfc464 sched/irq: handle NULL ISR handler in irq_default_handler
e143acfc464 is described below
commit e143acfc4642e53b5998f2b2dc617be4c0a48c4f
Author: hujun5 <[email protected]>
AuthorDate: Wed Mar 12 13:03:19 2025 +0800
sched/irq: handle NULL ISR handler in irq_default_handler
Add null-check for ISR handler before invoking in irq_default_handler.
Fix comment documentation and initialize return value to IRQ_WAKE_THREAD.
Ensures safe handler invocation when isr parameter is NULL in threaded IRQ
mode.
Signed-off-by: hujun5 <[email protected]>
---
sched/irq/irq_attach_thread.c | 8 +++++---
sched/irq/irq_attach_wqueue.c | 9 ++++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/sched/irq/irq_attach_thread.c b/sched/irq/irq_attach_thread.c
index 8c893a3002d..5e48a67f551 100644
--- a/sched/irq/irq_attach_thread.c
+++ b/sched/irq/irq_attach_thread.c
@@ -72,8 +72,10 @@ static int irq_default_handler(int irq, FAR void *regs, FAR
void *arg)
FAR struct irq_thread_info_s *info = arg;
int ret = IRQ_WAKE_THREAD;
- DEBUGASSERT(info->handler != NULL);
- ret = info->handler(irq, regs, info->arg);
+ if (info->handler != NULL)
+ {
+ ret = info->handler(irq, regs, info->arg);
+ }
if (ret == IRQ_WAKE_THREAD)
{
@@ -133,7 +135,7 @@ static int isr_thread_main(int argc, FAR char *argv[])
* irq - Irq num
* isr - Function to be called when the IRQ occurs, called in interrupt
* context.
- * If isr is NULL the default handler is installed(irq_default_handler).
+ * If isr is NULL, isrthread will be called.
* isrthread - called in thread context, If the isrthread is NULL,
* then the ISR is being detached.
* arg - privdate data
diff --git a/sched/irq/irq_attach_wqueue.c b/sched/irq/irq_attach_wqueue.c
index 7a63d8caccc..3c8554bd5e7 100644
--- a/sched/irq/irq_attach_wqueue.c
+++ b/sched/irq/irq_attach_wqueue.c
@@ -128,9 +128,12 @@ static void irq_work_handler(FAR void *arg)
static int irq_default_handler(int irq, FAR void *regs, FAR void *arg)
{
FAR struct irq_work_info_s *info = arg;
- int ret;
+ int ret = IRQ_WAKE_THREAD;
- ret = info->handler(irq, regs, arg);
+ if (info->handler != NULL)
+ {
+ ret = info->handler(irq, regs, info->arg);
+ }
if (ret == IRQ_WAKE_THREAD)
{
@@ -156,7 +159,7 @@ static int irq_default_handler(int irq, FAR void *regs, FAR
void *arg)
* irq - Irq num
* isr - Function to be called when the IRQ occurs, called in interrupt
* context.
- * If isr is NULL the default handler is installed(irq_default_handler).
+ * If isr is NULL, isrthread will be called.
* isrwork - called in thread context, If the isrwork is NULL,
* then the ISR is being detached.
* arg - privdate data