diff options
author | Chris Johns <chrisj@rtems.org> | 2014-12-22 11:50:31 +1100 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2015-02-24 12:53:29 -0500 |
commit | ee87007748e44aeedad7cbb6a4465714a323961c (patch) | |
tree | 256ed44fcc867e7e30b2e2ba0e9522043b6cb5d8 | |
parent | 9d090fb70ad46cae75ab4f55cac0176ebb9d7110 (diff) |
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.
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_glue.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c index 9d122e46a5..7484cce9c3 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, |