Skip to content

Commit b133260

Browse files
fix(core): validate thread priority at runtime
1 parent 2529550 commit b133260

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/scheduler_comm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ static rt_err_t _rt_sched_update_priority(struct rt_thread *thread, rt_uint8_t p
400400
*/
401401
rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t priority)
402402
{
403+
if (priority >= RT_THREAD_PRIORITY_MAX)
404+
{
405+
return -RT_EINVAL;
406+
}
407+
403408
return _rt_sched_update_priority(thread, priority, RT_FALSE);
404409
}
405410

@@ -408,6 +413,11 @@ rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t pr
408413
*/
409414
rt_err_t rt_sched_thread_reset_priority(struct rt_thread *thread, rt_uint8_t priority)
410415
{
416+
if (priority >= RT_THREAD_PRIORITY_MAX)
417+
{
418+
return -RT_EINVAL;
419+
}
420+
411421
return _rt_sched_update_priority(thread, priority, RT_TRUE);
412422
}
413423

0 commit comments

Comments
 (0)