Skip to content

Commit 259c32b

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>
1 parent 548f0e6 commit 259c32b

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
@@ -599,13 +599,23 @@ void mod_free_all(struct processing_module *mod)
599599
list_item_del(&container->list);
600600
}
601601

602+
list_for_item_safe(list, _list, &res->free_cont_list) {
603+
struct module_resource *container =
604+
container_of(list, struct module_resource, list);
605+
606+
list_item_del(&container->list);
607+
}
608+
602609
list_for_item_safe(list, _list, &res->cont_chunk_list) {
603610
struct container_chunk *chunk =
604611
container_of(list, struct container_chunk, chunk_list);
605612

606613
list_item_del(&chunk->chunk_list);
607614
rfree(chunk);
608615
}
616+
617+
/* Make sure resource lists and accounting are reset */
618+
mod_resource_init(mod);
609619
}
610620
EXPORT_SYMBOL(mod_free_all);
611621

0 commit comments

Comments
 (0)