This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch releases/13.1 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d77125d04b27c24246affb1c518a46e6da8bb2d0 Author: yushuailong <[email protected]> AuthorDate: Mon Sep 14 20:18:04 2026 +0800 sched/irq: Reject worked IRQs without a work queue. Return ENOMEM and leave the IRQ detached when no custom work queue can be created or all queue slots are occupied. Also release the queue mutex on the full-table path and avoid caching a failed queue creation. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <[email protected]> --- sched/irq/irq_attach_wqueue.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/sched/irq/irq_attach_wqueue.c b/sched/irq/irq_attach_wqueue.c index c89c11198c4..4ea2ad73551 100644 --- a/sched/irq/irq_attach_wqueue.c +++ b/sched/irq/irq_attach_wqueue.c @@ -88,7 +88,6 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority) if (wqueue_priority == priority) { - nxmutex_unlock(&irq_wqueue_lock); queue = irq_wqueue[i]; break; } @@ -99,10 +98,13 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority) queue = work_queue_create("isrwork", priority, irq_work_stack[i], CONFIG_IRQ_WORK_STACKSIZE, 1); - irq_wqueue[i] = queue; - nxmutex_unlock(&irq_wqueue_lock); + if (queue != NULL) + { + irq_wqueue[i] = queue; + } } + nxmutex_unlock(&irq_wqueue_lock); return queue; } @@ -176,6 +178,7 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork, int ret = OK; #if NR_IRQS > 0 int ndx = IRQ_TO_NDX(irq); + if (ndx < 0) { ret = ndx; @@ -196,16 +199,23 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork, } else { - info->isrwork = isrwork; - info->handler = isr; - info->arg = arg; - info->irq = irq; if (info->wqueue == NULL) { info->wqueue = irq_get_wqueue(priority); } - irq_attach(irq, irq_default_handler, info); + if (info->wqueue == NULL) + { + ret = -ENOMEM; + } + else + { + info->isrwork = isrwork; + info->handler = isr; + info->arg = arg; + info->irq = irq; + ret = irq_attach(irq, irq_default_handler, info); + } } } #endif /* NR_IRQS */
