From 3d69dbe1c8ac98516ce7e94a4a5a5cc58c03c16d Mon Sep 17 00:00:00 2001 From: anjiahao Date: Wed, 3 Apr 2024 09:54:26 +0800 Subject: [PATCH] deadlock:fix bug,When holder is -1 need stop search next Signed-off-by: anjiahao --- sched/misc/deadlock.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sched/misc/deadlock.c b/sched/misc/deadlock.c index bec9de9841..95ef9b02b2 100644 --- a/sched/misc/deadlock.c +++ b/sched/misc/deadlock.c @@ -71,6 +71,11 @@ static void collect_deadlock(FAR struct tcb_s *tcb, FAR void *arg) size_t i; next = ((FAR mutex_t *)sem)->holder; + if (next == NXMUTEX_NO_HOLDER) + { + break; + } + for (i = info->found; i < index; i++) { if (info->pid[i] == next) @@ -82,6 +87,10 @@ static void collect_deadlock(FAR struct tcb_s *tcb, FAR void *arg) info->pid[index] = tcb->pid; tcb = nxsched_get_tcb(next); + if (tcb == NULL) + { + break; + } } } }