vmh: fix allocation size check

When using non contiguous allocation block size is calculated after
the check.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
This commit is contained in:
Jakub Dabek 2024-02-09 16:32:09 +01:00 committed by Michal Wasko
parent 0fee9d9630
commit f23827a203
1 changed files with 4 additions and 3 deletions

View File

@ -263,9 +263,6 @@ void *vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size)
if (!heap->physical_blocks_allocators[mem_block_iterator])
continue;
/* If we do not span alloc and block is smaller than alloc we try next mem_block */
if (block_size < alloc_size && !heap->allocating_continuously)
continue;
/* calculate block count needed to allocate for current
* mem_block.
*/
@ -273,6 +270,10 @@ void *vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size)
1 << heap->physical_blocks_allocators[mem_block_iterator]->info.blk_sz_shift;
block_count = SOF_DIV_ROUND_UP((uint64_t)alloc_size, (uint64_t)block_size);
/* If we do not span alloc and block is smaller than alloc we try next mem_block */
if (block_size < alloc_size && !heap->allocating_continuously)
continue;
if (block_count >
heap->physical_blocks_allocators[mem_block_iterator]->info.num_blocks)
continue;