Module: xenomai-forge
Branch: master
Commit: d3c9c9fd078d7d9770ddee981dab027faf1ede27
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=d3c9c9fd078d7d9770ddee981dab027faf1ede27

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Jan  9 13:40:48 2014 +0100

cobalt/thread: trap obviously invalid rrb slice value

---

 kernel/cobalt/thread.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 3121c47..ed9937a 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -1360,11 +1360,14 @@ EXPORT_SYMBOL_GPL(xnthread_wait_period);
  * run next). Otherwise, if @a quantum equals XN_INFINITE,
  * time-slicing is stopped for that thread.
  *
- * @return 0 is returned upon success. Otherwise:
+ * @return 0 is returned upon success. Otherwise, -EINVAL is returned
+ * if @a quantum is not XN_INFINITE and:
+ *
+ *   - the base scheduling class of the target thread does not support
+ *   time-slicing,
  *
- * - -EINVAL is returned if @a quantum is not XN_INFINITE, and the
- * base scheduling class of the target thread does not support
- * time-slicing.
+ *   - @a quantum is smaller than the master clock gravity, which
+ * denotes a spurious value.
  *
  * @remark Tags: none.
  */
@@ -1373,6 +1376,9 @@ int xnthread_set_slice(struct xnthread *thread, xnticks_t 
quantum)
        struct xnsched *sched;
        spl_t s;
 
+       if (quantum <= xnclock_get_gravity(&nkclock))
+               return -EINVAL;
+
        xnlock_get_irqsave(&nklock, s);
 
        sched = thread->sched;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to