sched/irq: Cancel queued work before detaching worked IRQs.

Remove pending IRQ work before clearing its callback state, and guard the
worker callback against a concurrent detach.  This prevents detached worked
IRQs from invoking a NULL function pointer.

Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong
2026-09-16 00:02:45 +08:00
committed by Xiang Xiao
parent 6f98c6d38c
commit 36c0dce6d1
+10 -1
View File
@@ -115,8 +115,12 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority)
static void irq_work_handler(FAR void *arg)
{
FAR struct irq_work_info_s *info = arg;
xcpt_t isrwork = info->isrwork;
info->isrwork(info->irq, NULL, info->arg);
if (isrwork != NULL)
{
isrwork(info->irq, NULL, info->arg);
}
}
static int irq_default_handler(int irq, FAR void *context, FAR void *arg)
@@ -192,6 +196,11 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork,
if (isrwork == NULL)
{
irq_detach(irq);
if (info->wqueue != NULL)
{
work_cancel_wq(info->wqueue, &info->work);
}
info->isrwork = NULL;
info->handler = NULL;
info->arg = NULL;