[PATCH 06/12] rtems: Ensure lock ownership for _Region_Get()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 8 06:49:21 UTC 2016


---
 cpukit/rtems/include/rtems/rtems/regionimpl.h | 3 +++
 cpukit/rtems/src/regiondelete.c               | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/cpukit/rtems/include/rtems/rtems/regionimpl.h b/cpukit/rtems/include/rtems/rtems/regionimpl.h
index 724a1c1..4598351 100644
--- a/cpukit/rtems/include/rtems/rtems/regionimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/regionimpl.h
@@ -18,6 +18,8 @@
 #define _RTEMS_RTEMS_REGIONIMPL_H
 
 #include <rtems/rtems/region.h>
+#include <rtems/score/apimutex.h>
+#include <rtems/score/assert.h>
 #include <rtems/score/heapimpl.h>
 #include <rtems/score/objectimpl.h>
 #include <rtems/score/threadqimpl.h>
@@ -79,6 +81,7 @@ RTEMS_INLINE_ROUTINE Region_Control *_Region_Get (
   Objects_Locations *location
 )
 {
+  _Assert( _RTEMS_Allocator_is_owner() );
   return (Region_Control *)
     _Objects_Get_no_protection( &_Region_Information, id, location );
 }
diff --git a/cpukit/rtems/src/regiondelete.c b/cpukit/rtems/src/regiondelete.c
index bf6e461..f256423 100644
--- a/cpukit/rtems/src/regiondelete.c
+++ b/cpukit/rtems/src/regiondelete.c
@@ -35,6 +35,7 @@ rtems_status_code rtems_region_delete(
   Region_Control     *the_region;
 
   _Objects_Allocator_lock();
+  _RTEMS_Lock_allocator();
 
     the_region = _Region_Get( id, &location );
     switch ( location ) {
@@ -59,6 +60,7 @@ rtems_status_code rtems_region_delete(
         break;
     }
 
+  _RTEMS_Unlock_allocator();
   _Objects_Allocator_unlock();
 
   return return_status;
-- 
1.8.4.5




More information about the devel mailing list