Skip to content

Commit

Permalink
group/exitinof: replace spin_lock to critical_section avoid deadlock
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
anchao committed Oct 13, 2024
1 parent c37b0de commit 1ff49f0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sched/group/group_exitinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <errno.h>

#include <nuttx/sched.h>
#include <nuttx/spinlock.h>
#include <nuttx/binfmt/binfmt.h>

#include "sched/sched.h"
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 1ff49f0

Please sign in to comment.