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 6d2443924f74977860ddda0953ce3a6eced926a9 Author: yushuailong <[email protected]> AuthorDate: Mon Sep 14 20:17:11 2026 +0800 sched/irq: Keep threaded IRQ slots free after create failure. Store the thread PID only after kthread_create succeeds. This prevents a negative error value from making subsequent attachment attempts fail with EINVAL after a transient thread creation failure. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <[email protected]> --- sched/irq/irq_attach_thread.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sched/irq/irq_attach_thread.c b/sched/irq/irq_attach_thread.c index 2cad59a4d2d..a7bf55fdfd5 100644 --- a/sched/irq/irq_attach_thread.c +++ b/sched/irq/irq_attach_thread.c @@ -156,6 +156,7 @@ int irq_attach_thread(int irq, xcpt_t isr, xcpt_t isrthread, FAR void *arg, char arg4[32]; /* arg */ pid_t pid; int ndx = IRQ_TO_NDX(irq); + if (ndx < 0) { ret = ndx; @@ -191,8 +192,10 @@ int irq_attach_thread(int irq, xcpt_t isr, xcpt_t isrthread, FAR void *arg, { ret = pid; } - - irq_thread_pid[ndx] = pid; + else + { + irq_thread_pid[ndx] = pid; + } } #endif /* NR_IRQS */
