From 1ff49f0dfa13738236cc64a6d74b47843ab55f6a Mon Sep 17 00:00:00 2001 From: chao an Date: Sun, 13 Oct 2024 09:58:22 +0800 Subject: [PATCH] group/exitinof: replace spin_lock to critical_section avoid deadlock holding the irqsaved spinlock first and then take critical section may cause deadlock in SMP case replace spin_lock to critical_section avoid deadlock Signed-off-by: chao an --- sched/group/group_exitinfo.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sched/group/group_exitinfo.c b/sched/group/group_exitinfo.c index 22987a76b47a9..488b6840bc4cb 100644 --- a/sched/group/group_exitinfo.c +++ b/sched/group/group_exitinfo.c @@ -31,7 +31,6 @@ #include #include -#include #include #include "sched/sched.h" @@ -70,14 +69,14 @@ int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo) irqstate_t flags; DEBUGASSERT(bininfo != NULL); - flags = spin_lock_irqsave(NULL); + flags = enter_critical_section(); /* Get the TCB associated with the PID */ tcb = nxsched_get_tcb(pid); if (tcb == NULL) { - spin_unlock_irqrestore(NULL, flags); + leave_critical_section(flags); return -ESRCH; } @@ -90,7 +89,7 @@ int group_exitinfo(pid_t pid, FAR struct binary_s *bininfo) group->tg_bininfo = bininfo; - spin_unlock_irqrestore(NULL, flags); + leave_critical_section(flags); return OK; }