From 0794197f729f5ee9551dc7b2e14867f394cbc327 Mon Sep 17 00:00:00 2001 From: Kuan-Hsun Chen Date: Fri, 27 Jan 2017 23:15:50 +0100 Subject: rtems: Fix _Rate_monotonic_Renew_deadline() Prepare a precondition to prevent the potential integer overflow. Remove one redundant parameter in _Rate_monotonic_Renew_deadline(). sptests/sprmsched02: Create A test case for checking the overflow condition of postponed_jobs in rtems_rate_monotonic_period_status. Update #2885. --- cpukit/rtems/src/ratemontimeout.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c index bcc4ccfbf8..5a838fd916 100644 --- a/cpukit/rtems/src/ratemontimeout.c +++ b/cpukit/rtems/src/ratemontimeout.c @@ -9,7 +9,7 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * COPYRIGHT (c) 2016 Kuan-Hsun Chen. + * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -24,13 +24,16 @@ static void _Rate_monotonic_Renew_deadline( Rate_monotonic_Control *the_period, - Thread_Control *owner, ISR_lock_Context *lock_context ) { uint64_t deadline; - ++the_period->postponed_jobs; + /* stay at 0xffffffff if postponed_jobs is going to overflow */ + if ( the_period->postponed_jobs != UINT32_MAX ) { + ++the_period->postponed_jobs; + } + the_period->state = RATE_MONOTONIC_EXPIRED; deadline = _Watchdog_Per_CPU_insert_relative( @@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog ) _Thread_Unblock( owner ); } } else { - _Rate_monotonic_Renew_deadline( the_period, owner, &lock_context ); + _Rate_monotonic_Renew_deadline( the_period, &lock_context ); } } -- cgit v1.2.3