diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 0d74f5c4f72b..f3c39ebdf9e5 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -324,13 +324,11 @@ static struct mm_heap *get_heap_from_ptr(void *ptr) static struct mm_heap *get_heap_from_caps(struct mm_heap *heap, int count, uint32_t caps) { - uint32_t mask; int i; /* find first heap that support type */ for (i = 0; i < count; i++) { - mask = heap[i].caps & caps; - if (mask == caps) + if (heap[i].caps & caps) return &heap[i]; } @@ -647,8 +645,8 @@ static void *alloc_heap_buffer(struct mm_heap *heap, int zone, uint32_t caps, for (i = heap->blocks - 1; i >= 0; i--) { map = &heap->map[i]; - /* allocate if block size is smaller than request */ - if (heap->size >= bytes && map->block_size < bytes) { + /* does whole heap have enough space? */ + if (heap->size >= bytes) { ptr = alloc_cont_blocks(heap, i, caps, bytes); if (ptr) break;