mirror of
https://github.com/apache/nuttx.git
synced 2026-09-21 13:25:12 +08:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user