[rtems commit] Panic on RTEMS_FAST_MUTEX network semaphore claim/release.

Gedare Bloom gedare at rtems.org
Tue Feb 24 17:53:37 UTC 2015


Module:    rtems
Branch:    master
Commit:    ee87007748e44aeedad7cbb6a4465714a323961c
Changeset: http://git.rtems.org/rtems/commit/?id=ee87007748e44aeedad7cbb6a4465714a323961c

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Dec 22 11:50:31 2014 +1100

Panic on RTEMS_FAST_MUTEX network semaphore claim/release.

Fix the code to panic rather than perform a bad access if the network
semaphore is accessed without the stack being intialised.

Closes #2229.

---

 cpukit/libnetworking/rtems/rtems_glue.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index 9d122e4..7484cce 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -117,9 +117,12 @@ uint32_t
 rtems_bsdnet_semaphore_release_recursive(void)
 {
 #ifdef RTEMS_FAST_MUTEX
-	uint32_t nest_count = the_networkSemaphore->Core_control.mutex.nest_count;
+	uint32_t nest_count;
 	uint32_t i;
 
+	nest_count =
+		the_networkSemaphore ?
+		the_networkSemaphore->Core_control.mutex.nest_count : 0;
 	for (i = 0; i < nest_count; ++i) {
 		rtems_bsdnet_semaphore_release();
 	}
@@ -379,6 +382,8 @@ rtems_bsdnet_semaphore_obtain (void)
 	_Thread_Disable_dispatch();
 #endif
 	_ISR_Disable (level);
+	if (!the_networkSemaphore)
+		rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
 	executing = _Thread_Executing;
 	_CORE_mutex_Seize (
 		&the_networkSemaphore->Core_control.mutex,
@@ -414,6 +419,8 @@ rtems_bsdnet_semaphore_release (void)
 	int i;
 
 	_Thread_Disable_dispatch();
+	if (!the_networkSemaphore)
+		rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
 	i = _CORE_mutex_Surrender (
 		&the_networkSemaphore->Core_control.mutex,
 		networkSemaphore,




More information about the vc mailing list