This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 4a7915e sched: Check g_pidhash[hash_ndx] isn't NULL before access pid
field in nxsched_get_tcb
4a7915e is described below
commit 4a7915e72ba037ddadb1347c9f2fda1388be37d8
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun Oct 17 14:20:07 2021 +0800
sched: Check g_pidhash[hash_ndx] isn't NULL before access pid field in
nxsched_get_tcb
Fix the regression by commit:
commit 8b67944c75b81d17174bd207ad63acfa22da8983
Author: Xiang Xiao <[email protected]>
Date: Thu Oct 14 11:03:07 2021 +0800
sched: Remove pidhash_s and move ticks to tcb_s
simplify the code logic and reduce memory a little bit
Signed-off-by: Xiang Xiao <[email protected]>
Signed-off-by: Xiang Xiao <[email protected]>
---
sched/sched/sched_gettcb.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sched/sched/sched_gettcb.c b/sched/sched/sched_gettcb.c
index 9ee502c..3e38f51 100644
--- a/sched/sched/sched_gettcb.c
+++ b/sched/sched/sched_gettcb.c
@@ -56,6 +56,8 @@ FAR struct tcb_s *nxsched_get_tcb(pid_t pid)
irqstate_t flags;
int hash_ndx;
+ flags = enter_critical_section();
+
/* Verify whether g_pidhash hash table has already been allocated and
* whether the PID is within range.
*/
@@ -68,24 +70,22 @@ FAR struct tcb_s *nxsched_get_tcb(pid_t pid)
* terminating asynchronously.
*/
- flags = enter_critical_section();
-
/* Get the hash_ndx associated with the pid */
hash_ndx = PIDHASH(pid);
/* Verify that the correct TCB was found. */
- if (g_pidhash && pid == g_pidhash[hash_ndx]->pid)
+ if (g_pidhash[hash_ndx] != NULL && pid == g_pidhash[hash_ndx]->pid)
{
/* Return the TCB associated with this pid (if any) */
ret = g_pidhash[hash_ndx];
}
-
- leave_critical_section(flags);
}
+ leave_critical_section(flags);
+
/* Return the TCB. */
return ret;