Skip to content

Audio modules fixes#10752

Open
lgirdwood wants to merge 3 commits intothesofproject:mainfrom
lgirdwood:topic/audio-fixes
Open

Audio modules fixes#10752
lgirdwood wants to merge 3 commits intothesofproject:mainfrom
lgirdwood:topic/audio-fixes

Conversation

@lgirdwood
Copy link
Copy Markdown
Member

Some small fixes picked up by the audio ztest UTs.

lrgirdwo added 3 commits May 6, 2026 16:54
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>
Copilot AI review requested due to automatic review settings May 7, 2026 19:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants