Audio modules fixes#10752
Open
lgirdwood wants to merge 3 commits intothesofproject:mainfrom
Open
Conversation
Properly track allocation state in the ASRC component lifecycle to prevent double-free of heap memory during module teardown in ZTest environments. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add input validation for the frame_shift configuration field in mfcc_setup(). A zero or negative value would cause a division by zero during STFT processing. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add null checks for hardware device pointers that may not be available when running in ZTest environments without real hardware. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a few robustness issues in the audio modules that were surfaced by the audio ztest unit tests, primarily by adding missing validation and making teardown paths safer.
Changes:
- Add Zephyr
device_is_ready()gating to mic privacy manager initialization and guard policy queries when the device isn’t initialized. - Add MFCC configuration validation to reject non-positive
frame_shift. - Harden ASRC free/reset paths by adding NULL checks, clearing pointers after freeing, and resetting module private data.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/audio/mic_privacy_manager/mic_privacy_manager_intel.c |
Add device readiness check during init and a guard in get_policy() to avoid dereferencing an uninitialized device pointer. |
src/audio/mfcc/mfcc_setup.c |
Add basic validation for frame_shift to prevent invalid hop sizes. |
src/audio/asrc/asrc.c |
Make free()/reset() more defensive by checking allocations before releasing and nulling pointers after free. |
Comment on lines
+98
to
+101
| if (!device_is_ready(mic_priv_dev)) { | ||
| LOG_ERR("mic_privacy device not ready"); | ||
| return -ENODEV; | ||
| } |
Comment on lines
156
to
+161
| fft->fft_size = config->frame_length; | ||
| fft->fft_padded_size = 1 << (31 - norm_int32(fft->fft_size)); /* Round up to nearest 2^N */ | ||
| if (config->frame_shift <= 0) { | ||
| comp_err(dev, "frame_shift must be positive"); | ||
| return -EINVAL; | ||
| } |
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.
Some small fixes picked up by the audio ztest UTs.