summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-10 12:42:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-12 10:09:04 +0200
commit9399e12c217343545bf412a01629570377536b39 (patch)
treee8a7f068a355bd18d15e745eec7b3c1611ae2f57 /cpukit/rtems
parentbsps/arm: More robust SMP start (diff)
downloadrtems-9399e12c217343545bf412a01629570377536b39.tar.bz2
rtems: Fix rtems_partition_return_buffer()
The rtems_partition_return_buffer() wrongly accepted which were exactly at the buffer area end. Use the buffer area limit address for the range checking. Close #4490.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/src/partcreate.c8
-rw-r--r--cpukit/rtems/src/partreturnbuffer.c17
2 files changed, 16 insertions, 9 deletions
diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index 012a416a1a..61249749f3 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -23,6 +23,7 @@
#include <rtems/rtems/partimpl.h>
#include <rtems/rtems/attrimpl.h>
#include <rtems/rtems/support.h>
+#include <rtems/score/address.h>
#include <rtems/score/chainimpl.h>
#include <rtems/score/sysstate.h>
#include <rtems/sysinit.h>
@@ -40,8 +41,11 @@ static void _Partition_Initialize(
rtems_attribute attribute_set
)
{
- the_partition->starting_address = starting_address;
- the_partition->length = length;
+ const void *limit_address;
+
+ limit_address = _Addresses_Add_offset( starting_address, length - 1 );
+ the_partition->base_address = starting_address;
+ the_partition->limit_address = limit_address;
the_partition->buffer_size = buffer_size;
the_partition->attribute_set = attribute_set;
the_partition->number_of_used_blocks = 0;
diff --git a/cpukit/rtems/src/partreturnbuffer.c b/cpukit/rtems/src/partreturnbuffer.c
index f5ab7d85f9..68302f1163 100644
--- a/cpukit/rtems/src/partreturnbuffer.c
+++ b/cpukit/rtems/src/partreturnbuffer.c
@@ -33,7 +33,7 @@ static bool _Partition_Is_address_on_buffer_boundary(
offset = _Addresses_Subtract(
the_buffer,
- the_partition->starting_address
+ the_partition->base_address
);
return ( offset % the_partition->buffer_size ) == 0;
@@ -44,14 +44,17 @@ static bool _Partition_Is_address_a_buffer_begin(
const void *the_buffer
)
{
- void *starting;
- void *ending;
+ const void *base;
+ const void *limit;
- starting = the_partition->starting_address;
- ending = _Addresses_Add_offset( starting, the_partition->length );
+ base = the_partition->base_address;
+ limit = the_partition->limit_address;
- return _Addresses_Is_in_range( the_buffer, starting, ending )
- && _Partition_Is_address_on_buffer_boundary( the_partition, the_buffer );
+ if ( !_Addresses_Is_in_range( the_buffer, base, limit ) ) {
+ return false;
+ }
+
+ return _Partition_Is_address_on_buffer_boundary( the_partition, the_buffer );
}
static void _Partition_Free_buffer(