Skip to content

Commit fcbca60

Browse files
committed
regions_mm: vmh_free: Prevent null pointer dereference
The vmh_free function may have referenced a null pointer if an invalid pointer was passed to it. Before referencing the allocator array item, check if it has been initialized. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent b95fc72 commit fcbca60

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

zephyr/lib/regions_mm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ int vmh_free(struct vmh_heap *heap, void *ptr)
571571
for (mem_block_iter = 0, ptr_range_found = false;
572572
mem_block_iter < MAX_MEMORY_ALLOCATORS_COUNT;
573573
mem_block_iter++) {
574+
if (!heap->physical_blocks_allocators[mem_block_iter])
575+
continue;
576+
574577
block_size =
575578
1 << heap->physical_blocks_allocators[mem_block_iter]->info.blk_sz_shift;
576579

0 commit comments

Comments
 (0)