Tools: Testbench: Fix notification pool memory leak#10741
Merged
kv2019i merged 3 commits intothesofproject:mainfrom May 4, 2026
Merged
Tools: Testbench: Fix notification pool memory leak#10741kv2019i merged 3 commits intothesofproject:mainfrom
kv2019i merged 3 commits intothesofproject:mainfrom
Conversation
This patch replaces the rfree() of cd->msg with ipc_msg_free() which properly unlinks the message from the IPC message queue before freeing it. The direct rfree() left a dangling list entry, causing a use-after-free when tb_free() drains the queue via ipc_send_queued_msg(). Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
In capture direction testbench runs, pipeline_comp_copy() triggers send_process_data_error_notif_msg() which allocates a notification from the pool and queues it to the IPC message list via ipc_msg_send(). On Zephyr targets a work handler calls ipc_send_queued_msg() to process the queue and invoke the free callback. In the testbench no such handler exists, so queued notifications are never freed. Add ipc_notification_pool_free() to notification_pool.c to release all pool items. In tb_free(), drain the IPC message queue by calling ipc_send_queued_msg() in a loop, then call ipc_notification_pool_free() to free the pool before releasing IPC resources. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The mfcc_free_buffers() need to be called before the component data cd is freed. The pointers to buffers are members of cd. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
ff6f3d1 to
e4aa893
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes teardown-time memory management issues in the testbench and audio modules so IPC notification/message allocations are released safely during pipeline shutdown. It fits into the codebase by tightening lifecycle cleanup paths for IPC-backed notifications and MFCC buffers.
Changes:
- Drain queued IPC notifications in testbench teardown and add a library-only notification-pool cleanup helper.
- Fix
sound_dose_free()to release IPC messages viaipc_msg_free()instead of manually freeing raw pointers. - Reorder
mfcc_free()cleanup so MFCC buffers are freed before the component private data is released.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tools/testbench/utils.c |
Drains queued IPC messages during testbench shutdown and frees notification-pool items. |
src/ipc/notification_pool.c |
Adds library-only cleanup for notification-pool allocations. |
src/include/sof/ipc/notification_pool.h |
Declares the new notification-pool cleanup API for library builds. |
src/audio/sound_dose/sound_dose.c |
Switches Sound Dose IPC message teardown to the common ipc_msg_free() helper. |
src/audio/mfcc/mfcc.c |
Fixes MFCC free ordering so buffer cleanup happens before freeing module data. |
tmleman
approved these changes
May 4, 2026
kv2019i
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two MFCC testbench run related memory leaks
The notification pool fix triggered an issue in Sound Dose that also needed a fix