set size before modifying it

This commit is contained in:
Tilen Majerle 2024-10-09 05:25:53 +02:00
parent 5887323fb0
commit 254ea2855f

View File

@ -198,6 +198,7 @@ prv_get_region_addr_size(const lwmem_region_t* region, uint8_t** msa, size_t* ms
* Increase start address and decrease effective region size
*/
mem_start_addr = region->start_addr;
mem_size = region->size;
if (((size_t)mem_start_addr) & LWMEM_ALIGN_BITS) { /* Check alignment boundary */
mem_start_addr += ((size_t)LWMEM_CFG_ALIGN_NUM) - ((size_t)mem_start_addr & LWMEM_ALIGN_BITS);
mem_size -= (size_t)(mem_start_addr - LWMEM_TO_BYTE_PTR(region->start_addr));