module: cadence / ipc4: Fix memory leak of notification IPC message#10798
Open
ujfalusi wants to merge 1 commit into
Open
module: cadence / ipc4: Fix memory leak of notification IPC message#10798ujfalusi wants to merge 1 commit into
ujfalusi wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a potential memory leak in the IPC4 Cadence module’s EOS (DRAIN/EOL) notification path by allocating a reusable IPC notification message once during module init and freeing it during module teardown, instead of allocating a new message on each notification send.
Changes:
- Add a persistent
struct ipc_msg *to Cadence codec private data (IPC4) to hold a notification template for the module lifetime. - Allocate/initialize the notification IPC message during
cadence_codec_init()and reuse it incadence_codec_process()when EOS is reached. - Free the allocated IPC message on init error paths and in a new IPC4-specific
.freeimplementation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/include/sof/audio/module_adapter/module/cadence.h | Adds an IPC4-only struct ipc_msg *msg field (with forward declaration) to store the reusable notification message. |
| src/audio/module_adapter/module/cadence_ipc4.c | Introduces notification message init helper, reuses the message on EOS, and frees it via IPC4-specific module free path. |
|
|
||
| static struct ipc_msg *cadence_codec_notification_init(struct processing_module *mod) | ||
| { | ||
| struct cadence_codec_data *cd = module_get_private_data(mod); |
Contributor
Author
There was a problem hiding this comment.
it is a leftover from previous version when I did the assignment in the function (and returning int error code), I'll remove it in v2
lyakh
approved these changes
May 21, 2026
Each notification that that is sent by the module could cause a memory leak in theory. Notification is only sent in case of DRAIN or EOL and multiple notification sending will be blocked by the eos_notification_sent flag. Since pipelines cannot recover from EOS state, this is theoretical until that is fixed, but it is a bug in the code never the less. Follow the example of other modules and store and allocate the notification message for the lifetime of the module to manage the allocation properly. Fixes: f6cfc4c ("module: cadence / ipc4: Support for EOS handling and notification to host") Reported-by: Jyri Sarha <jyri.sarha@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
d3ff967 to
2ca80d4
Compare
Contributor
Author
|
Changes since v1:
|
jsarha
approved these changes
May 21, 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.
Each notification that that is sent by the module could cause a memory leak in theory.
Notification is only sent in case of DRAIN or EOL and multiple notification sending will be blocked by the eos_notification_sent flag. Since pipelines cannot recover from EOS state, this is theoretical until that is fixed, but it is a bug in the code never the less.
Follow the example of other modules and store and allocate the notification message for the lifetime of the module to manage the allocation properly.
Fixes: f6cfc4c ("module: cadence / ipc4: Support for EOS handling and notification to host")
Reported-by: Jyri Sarha jyri.sarha@linux.intel.com