Skip to content

Commit 7f093fb

Browse files
committed
module_adapter: generic: Fix use after free
Remove any containers from the free container list so that we don't keep pointers to containers that are no longer used and will be freed when container chunks are released below. Leaving those nodes in the free container list would cause use-after-free on subsequent allocations. While at it, make sure all resource lists are reset. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> (cherry picked from commit 259c32b)
1 parent 8d8173b commit 7f093fb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/audio/module_adapter/module/generic.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,23 @@ void mod_free_all(struct processing_module *mod)
577577
list_item_del(&container->list);
578578
}
579579

580+
list_for_item_safe(list, _list, &res->free_cont_list) {
581+
struct module_resource *container =
582+
container_of(list, struct module_resource, list);
583+
584+
list_item_del(&container->list);
585+
}
586+
580587
list_for_item_safe(list, _list, &res->cont_chunk_list) {
581588
struct container_chunk *chunk =
582589
container_of(list, struct container_chunk, chunk_list);
583590

584591
list_item_del(&chunk->chunk_list);
585592
rfree(chunk);
586593
}
594+
595+
/* Make sure resource lists and accounting are reset */
596+
mod_resource_init(mod);
587597
}
588598
EXPORT_SYMBOL(mod_free_all);
589599

0 commit comments

Comments
 (0)