sched/sched: Validate priority before applying sporadic parameters.

nxsched_set_param() applied the sporadic parameters and restarted the
replenishment timer in set_sporadic_param() before nxsched_reprioritize()
rejected an out-of-range priority with EINVAL, leaving stale sporadic
state (e.g. a truncated hi_priority) behind on failure.

Validate sched_priority up front so the error path is atomic.

Assisted-by: OpenAI Codex
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong
2026-09-13 10:29:49 +08:00
committed by Xiang Xiao
parent eab468dcb2
commit 22d5ee5b2b
+6
View File
@@ -187,6 +187,12 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param)
if (param != NULL)
{
if (param->sched_priority < SCHED_PRIORITY_MIN ||
param->sched_priority > SCHED_PRIORITY_MAX)
{
return -EINVAL;
}
/* Prohibit modifications to the head of the ready-to-run task
* list while adjusting the priority
*/