mirror of https://github.com/thesofproject/sof.git
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:
parent
da5073737c
commit
04fa66ad11
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue