mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-30 02:57:17 +08:00
rtems_flashdev_register() cleared the region allocator bitmap with memset( table->bit_allocator, 0, alloc_array_len ) where alloc_array_len held the number of uint32_t words. Since bit_allocator is a uint32_t array, only one byte per word was zeroed, leaving the rest of the bitmap uninitialised. Stale bits can make rtems_flashdev_find_unallocated_region() report region slots as allocated and fail REGION_SET with ENOMEM while slots are actually free. Rename RTEMS_FLASHDEV_BITALLOC_LENGTH to RTEMS_FLASHDEV_BITALLOC_WORD_LENGTH to make the word count explicit, add RTEMS_FLASHDEV_BITALLOC_BYTE_LENGTH for the size in bytes, and clear the whole bitmap using the byte length.