|
@@ -8746,6 +8746,8 @@ sysret_t sys_sysinfo(void *info)
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static rt_bool_t _sys_sched_priority_is_valid(int priority);
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @brief Set scheduling parameters for a specific thread.
|
|
* @brief Set scheduling parameters for a specific thread.
|
|
|
*
|
|
*
|
|
@@ -8785,6 +8787,12 @@ sysret_t sys_sched_setparam(pid_t tid, void *param)
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!_sys_sched_priority_is_valid(sched_param->sched_priority))
|
|
|
|
|
+ {
|
|
|
|
|
+ kmem_put(sched_param);
|
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
thread = lwp_tid_get_thread_and_inc_ref(tid);
|
|
thread = lwp_tid_get_thread_and_inc_ref(tid);
|
|
|
|
|
|
|
|
if (thread)
|
|
if (thread)
|
|
@@ -8915,6 +8923,18 @@ sysret_t sys_sched_get_priority_min(int policy)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static rt_bool_t _sys_sched_priority_is_valid(int priority)
|
|
|
|
|
+{
|
|
|
|
|
+ return (priority >= 0) && (priority < RT_THREAD_PRIORITY_MAX);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#if defined(RT_USING_UTESTCASES) && defined(RT_USING_SMART)
|
|
|
|
|
+rt_bool_t rt_utest_sys_sched_priority_is_valid(int priority)
|
|
|
|
|
+{
|
|
|
|
|
+ return _sys_sched_priority_is_valid(priority);
|
|
|
|
|
+}
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @brief Set the scheduling policy and parameters for a thread.
|
|
* @brief Set the scheduling policy and parameters for a thread.
|
|
|
*
|
|
*
|
|
@@ -8958,6 +8978,12 @@ sysret_t sys_sched_setscheduler(int tid, int policy, void *param)
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!_sys_sched_priority_is_valid(sched_param->sched_priority))
|
|
|
|
|
+ {
|
|
|
|
|
+ kmem_put(sched_param);
|
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
thread = lwp_tid_get_thread_and_inc_ref(tid);
|
|
thread = lwp_tid_get_thread_and_inc_ref(tid);
|
|
|
ret = rt_thread_control(thread, RT_THREAD_CTRL_RESET_PRIORITY, (void *)&sched_param->sched_priority);
|
|
ret = rt_thread_control(thread, RT_THREAD_CTRL_RESET_PRIORITY, (void *)&sched_param->sched_priority);
|
|
|
lwp_tid_dec_ref(thread);
|
|
lwp_tid_dec_ref(thread);
|