From 8dcc846eb4b2b411f2c0bd8b9d7e606804657aa7 Mon Sep 17 00:00:00 2001
From: Chris Johns <chrisj@rtems.org>
Date: Mon, 22 Dec 2014 11:50:31 +1100
Subject: [PATCH] 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
|
b
|
uint32_t |
117 | 117 | rtems_bsdnet_semaphore_release_recursive(void) |
118 | 118 | { |
119 | 119 | #ifdef RTEMS_FAST_MUTEX |
120 | | uint32_t nest_count = the_networkSemaphore->Core_control.mutex.nest_count; |
| 120 | uint32_t nest_count; |
121 | 121 | uint32_t i; |
122 | 122 | |
| 123 | nest_count = |
| 124 | the_networkSemaphore ? |
| 125 | the_networkSemaphore->Core_control.mutex.nest_count : 0; |
123 | 126 | for (i = 0; i < nest_count; ++i) { |
124 | 127 | rtems_bsdnet_semaphore_release(); |
125 | 128 | } |
… |
… |
rtems_bsdnet_semaphore_obtain (void) |
379 | 382 | _Thread_Disable_dispatch(); |
380 | 383 | #endif |
381 | 384 | _ISR_Disable (level); |
| 385 | if (!the_networkSemaphore) |
| 386 | rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); |
382 | 387 | executing = _Thread_Executing; |
383 | 388 | _CORE_mutex_Seize ( |
384 | 389 | &the_networkSemaphore->Core_control.mutex, |
… |
… |
rtems_bsdnet_semaphore_release (void) |
414 | 419 | int i; |
415 | 420 | |
416 | 421 | _Thread_Disable_dispatch(); |
| 422 | if (!the_networkSemaphore) |
| 423 | rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); |
417 | 424 | i = _CORE_mutex_Surrender ( |
418 | 425 | &the_networkSemaphore->Core_control.mutex, |
419 | 426 | networkSemaphore, |