mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
sched/clock Add special handling for TCB null pointer cases
Adding a judgment in the code that null return values are not referenced for dereference Signed-off-by: zhuanglin <zhuanglin@xiaomi.com>
This commit is contained in:
+28
-11
@@ -153,7 +153,14 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
|||||||
tcb = nxsched_get_tcb(pid);
|
tcb = nxsched_get_tcb(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
up_perf_convert(tcb->run_time, tp);
|
if (tcb != NULL)
|
||||||
|
{
|
||||||
|
up_perf_convert(tcb->run_time, tp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = -EFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (clock_type == CLOCK_PROCESS_CPUTIME_ID)
|
else if (clock_type == CLOCK_PROCESS_CPUTIME_ID)
|
||||||
{
|
{
|
||||||
@@ -174,18 +181,28 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
|||||||
tcb = nxsched_get_tcb(pid);
|
tcb = nxsched_get_tcb(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
group = tcb->group;
|
if (tcb != NULL)
|
||||||
runtime = 0;
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
for (i = group->tg_nmembers - 1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
tcb = nxsched_get_tcb(group->tg_members[i]);
|
group = tcb->group;
|
||||||
runtime += tcb->run_time;
|
runtime = 0;
|
||||||
}
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
flags = enter_critical_section();
|
||||||
up_perf_convert(runtime, tp);
|
for (i = group->tg_nmembers - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
tcb = nxsched_get_tcb(group->tg_members[i]);
|
||||||
|
if (tcb != NULL)
|
||||||
|
{
|
||||||
|
runtime += tcb->run_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
|
up_perf_convert(runtime, tp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = -EFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user