Changeset 39e6f532 in rtems


Ignore:
Timestamp:
Dec 7, 2021, 3:31:45 PM (6 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ffc57e3
Parents:
e543a16
git-author:
Sebastian Huber <sebastian.huber@…> (12/07/21 15:31:45)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/07/21 15:32:54)
Message:

score: Fix _Workspace_Initialize_for_one_area()

In _Workspace_Initialize_for_one_area(), properly check if there is enough
free memory available for the configured workspace size.

The bug was introduced by commit 3d0620b607ff6459fec9d30efc1e0589bbd010f9.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/wkspaceinitone.h

    re543a16 r39e6f532  
    6060RTEMS_INLINE_ROUTINE void _Workspace_Initialize_for_one_area( void )
    6161{
    62   uintptr_t page_size;
    63   uintptr_t wkspace_size;
    64   uintptr_t wkspace_size_with_overhead;
    65   uintptr_t available_size;
     62  uintptr_t                 page_size;
     63  uintptr_t                 wkspace_size;
     64  uintptr_t                 wkspace_size_with_overhead;
     65  const Memory_Information *mem;
     66  Memory_Area              *area;
     67  uintptr_t                 free_size;
     68  uintptr_t                 available_size;
    6669
    6770  page_size = CPU_HEAP_ALIGNMENT;
     
    6972  wkspace_size_with_overhead = wkspace_size + _Heap_Area_overhead( page_size );
    7073
    71   if ( wkspace_size < wkspace_size_with_overhead ) {
    72     const Memory_Information *mem;
    73     Memory_Area              *area;
    74     uintptr_t                 free_size;
    75     uintptr_t                 size;
     74  mem = _Memory_Get();
     75  _Assert( _Memory_Get_count( mem ) == 1 );
    7676
    77     mem = _Memory_Get();
    78     _Assert( _Memory_Get_count( mem ) == 1 );
     77  area = _Memory_Get_area( mem, 0 );
     78  free_size = _Memory_Get_free_size( area );
    7979
    80     area = _Memory_Get_area( mem, 0 );
    81     free_size = _Memory_Get_free_size( area );
     80  if (
     81    wkspace_size < wkspace_size_with_overhead &&
     82    free_size >= wkspace_size_with_overhead
     83  ) {
     84    uintptr_t size;
    8285
    8386    if ( rtems_configuration_get_unified_work_area() ) {
     
    9699    _Memory_Consume( area, size );
    97100  } else {
    98     /* An unsigned integer overflow happened */
     101    /*
     102     * An unsigned integer overflow happened, or the available free memory is
     103     * not enough.
     104     */
    99105    available_size = 0;
    100106  }
Note: See TracChangeset for help on using the changeset viewer.