This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 22d5ee5b2bc2df59423bdcea684b51c8a0ae532c Author: yushuailong <[email protected]> AuthorDate: Mon Sep 7 00:34:16 2026 +0800 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 <[email protected]> --- sched/sched/sched_setparam.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sched/sched/sched_setparam.c b/sched/sched/sched_setparam.c index a302e6e660e..61e8c7a1b04 100644 --- a/sched/sched/sched_setparam.c +++ b/sched/sched/sched_setparam.c @@ -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 */
