Skip to content

Commit ffd605c

Browse files
author
Jyri Sarha
committed
module_adapter: Add mod_free() check to module_adapter_free()
Add module memory leak check to module_adapter_free(). The check goes through the module specific memory allocations list and frees unfreed memory and prints warning if there was any. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 6471671 commit ffd605c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/audio/module_adapter/module_adapter.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,18 +1202,18 @@ EXPORT_SYMBOL(module_adapter_reset);
12021202

12031203
void module_adapter_free(struct comp_dev *dev)
12041204
{
1205-
int ret;
1205+
int ret, err_count = 0;
12061206
struct processing_module *mod = comp_mod(dev);
1207-
struct list_item *blist, *_blist;
1207+
struct list_item *listp, *_listp;
12081208

12091209
comp_dbg(dev, "module_adapter_free(): start");
12101210

12111211
ret = module_free(mod);
12121212
if (ret)
12131213
comp_err(dev, "module_adapter_free(): failed with error: %d", ret);
12141214

1215-
list_for_item_safe(blist, _blist, &mod->raw_data_buffers_list) {
1216-
struct comp_buffer *buffer = container_of(blist, struct comp_buffer,
1215+
list_for_item_safe(listp, _listp, &mod->raw_data_buffers_list) {
1216+
struct comp_buffer *buffer = container_of(listp, struct comp_buffer,
12171217
buffers_list);
12181218
uint32_t flags;
12191219

@@ -1223,6 +1223,17 @@ void module_adapter_free(struct comp_dev *dev)
12231223
buffer_free(buffer);
12241224
}
12251225

1226+
list_for_item_safe(listp, _listp, &mod->priv.memory.mem_list) {
1227+
struct module_memory *mem = container_of(listp, struct module_memory, mem_list);
1228+
1229+
rfree(mem->ptr);
1230+
list_item_del(&mem->mem_list);
1231+
rfree(mem);
1232+
err_count++;
1233+
}
1234+
1235+
if (err_count)
1236+
comp_warn(dev, "%d memory chunks freed for %#x", err_count, dev_comp_id(dev));
12261237
#if CONFIG_IPC_MAJOR_4
12271238
rfree(mod->priv.cfg.input_pins);
12281239
#endif

0 commit comments

Comments
 (0)