memory: fixed memory leak

Fix for memory leak when freeing continuous blocks.
Untill now only one block was freed since hdr->size was zeroed
at every loop pass and as it was part of loop condition loop has
been fired only once even if there were more than one blocks
to free.

Signed-off-by: Jakub Dabek <jakub.dabek@linux.intel.com>
This commit is contained in:
Jakub Dabek 2018-12-05 13:58:48 +01:00 committed by Liam Girdwood
parent da5073737c
commit 04fa66ad11
1 changed files with 4 additions and 1 deletions

View File

@ -332,6 +332,7 @@ static void free_block(void *ptr)
struct block_hdr *hdr;
int i;
int block;
int used_blocks;
heap = get_heap_from_ptr(ptr);
if (!heap) {
@ -366,7 +367,9 @@ found:
panic(SOF_IPC_PANIC_MEM);
/* free block header and continuous blocks */
for (i = block; i < block + hdr->size; i++) {
used_blocks = block + hdr->size;
for (i = block; i < used_blocks; i++) {
hdr = cache_to_uncache(&block_map->block[i]);
hdr->size = 0;
hdr->used = 0;