summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-10 07:44:45 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-10 07:50:00 +0200
commit6641cc87b87e0abf79138bbe0fbd303e04b547bf (patch)
treef936a51c4619aafdbd31a97ae8927d0826510941 /cpukit
parentf83676d91f3c639c93097733f2b2ffa54ec10599 (diff)
downloadrtems-6641cc87b87e0abf79138bbe0fbd303e04b547bf.tar.bz2
score: Fix initialization of thread queue context
Set Thread_queue_Context::timeout_absolute in _Thread_queue_Context_set_timeout_argument() to avoid using it uninitialized. The bug was introduced by a89ecaa1a94d49ddae7753d6b83923e9d2a00486.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/include/rtems/score/threadqimpl.h12
-rw-r--r--cpukit/posix/src/condwaitsupp.c2
-rw-r--r--cpukit/posix/src/mqueuerecvsupp.c2
-rw-r--r--cpukit/posix/src/mqueuesendsupp.c2
-rw-r--r--cpukit/posix/src/mutexlocksupp.c2
-rw-r--r--cpukit/score/src/condition.c4
6 files changed, 15 insertions, 9 deletions
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index 7b00de009d..44efc1fcd0 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -201,18 +201,24 @@ _Thread_queue_Context_set_timeout_ticks(
/**
* @brief Sets the timeout argument in the thread queue context.
*
- * @param[out] queue_context The thread queue context.
- * @param arg The timeout argument.
+ * @param[out] queue_context is the thread queue context.
+ *
+ * @param arg is the timeout argument.
+ *
+ * @param absolute is true, if the timeout shall be absolute, otherwise it
+ * shall be relative to the current time of the clock.
*
* @see _Thread_queue_Enqueue().
*/
RTEMS_INLINE_ROUTINE void
_Thread_queue_Context_set_timeout_argument(
Thread_queue_Context *queue_context,
- const void *arg
+ const void *arg,
+ bool absolute
)
{
queue_context->Timeout.arg = arg;
+ queue_context->timeout_absolute = absolute;
}
/**
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index 296c03d1c6..ee2f8a0787 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -109,7 +109,7 @@ int _POSIX_Condition_variables_Wait_support(
_Thread_queue_Context_initialize( &queue_context );
if ( abstime != NULL ) {
- _Thread_queue_Context_set_timeout_argument( &queue_context, abstime );
+ _Thread_queue_Context_set_timeout_argument( &queue_context, abstime, true );
if ( _POSIX_Condition_variables_Get_clock( flags ) == CLOCK_MONOTONIC ) {
_Thread_queue_Context_set_enqueue_callout(
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index 2adcb7b3b2..9c26bf100b 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -69,7 +69,7 @@ ssize_t _POSIX_Message_queue_Receive_support(
}
_Thread_queue_Context_set_enqueue_callout( &queue_context, enqueue_callout );
- _Thread_queue_Context_set_timeout_argument( &queue_context, abstime );
+ _Thread_queue_Context_set_timeout_argument( &queue_context, abstime, true );
/*
* Now if something goes wrong, we return a "length" of -1
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 7be23fc595..328a01ece4 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -70,7 +70,7 @@ int _POSIX_Message_queue_Send_support(
}
_Thread_queue_Context_set_enqueue_callout( &queue_context, enqueue_callout );
- _Thread_queue_Context_set_timeout_argument( &queue_context, abstime );
+ _Thread_queue_Context_set_timeout_argument( &queue_context, abstime, true );
_CORE_message_queue_Acquire_critical(
&the_mq->Message_queue,
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index e5bd1784ea..983ee578ad 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -69,7 +69,7 @@ int _POSIX_Mutex_Lock_support(
executing = _POSIX_Mutex_Acquire( the_mutex, &queue_context );
_Thread_queue_Context_set_enqueue_callout( &queue_context, enqueue_callout);
- _Thread_queue_Context_set_timeout_argument( &queue_context, abstime );
+ _Thread_queue_Context_set_timeout_argument( &queue_context, abstime, true );
switch ( _POSIX_Mutex_Get_protocol( flags ) ) {
case POSIX_MUTEX_PRIORITY_CEILING:
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index acc72fc1a6..f4dc372d33 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -188,7 +188,7 @@ int _Condition_Wait_timed(
&context.Base,
_Condition_Enqueue_with_timeout
);
- _Thread_queue_Context_set_timeout_argument( &context.Base, abstime );
+ _Thread_queue_Context_set_timeout_argument( &context.Base, abstime, true );
executing = _Condition_Do_wait( _condition, _mutex, &context );
eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );
_Mutex_Acquire( _mutex );
@@ -243,7 +243,7 @@ int _Condition_Wait_recursive_timed(
&context.Base,
_Condition_Enqueue_with_timeout
);
- _Thread_queue_Context_set_timeout_argument( &context.Base, abstime );
+ _Thread_queue_Context_set_timeout_argument( &context.Base, abstime, true );
nest_level = _Condition_Unnest_mutex( _mutex );
executing = _Condition_Do_wait( _condition, &_mutex->_Mutex, &context );
eno = STATUS_GET_POSIX( _Thread_Wait_get_status( executing ) );