mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
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 <hujun5@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user