Skip to content

Comments

module_adapter: dp: Improve module adapter creation function#10565

Open
softwarecki wants to merge 3 commits intothesofproject:mainfrom
softwarecki:adapter-fix
Open

module_adapter: dp: Improve module adapter creation function#10565
softwarecki wants to merge 3 commits intothesofproject:mainfrom
softwarecki:adapter-fix

Conversation

@softwarecki
Copy link
Collaborator

  • Add checking of the return value from pipeline_comp_dp_task_init() to ensure the dp thread is created successfully. This prevents execution from continuing with an invalid task.
  • Update scheduler_dp_task_init() to assign the output task pointer only on success. The function frees the allocated task structure on failure, so returning a non-null task could lead to a double free or use after free.
  • Move mod field initialization in module_adapter_new_ext() to occur before creating the dp thread. This prevents the thread from use uninitialized fields.

Move mod field initialization in module_adapter_new_ext() before creating
the dp thread. Moving the initialization earlier prevents the dp thread
from use uninitialized data.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Copilot AI review requested due to automatic review settings February 20, 2026 15:37
@softwarecki softwarecki changed the title module_adapter: dp: Improve adapter creation function module_adapter: dp: Improve module adapter creation function Feb 20, 2026
Copy link

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 improves error handling and initialization order in the module adapter creation flow for data processing tasks. The changes ensure that task creation failures are properly detected and handled, prevent potential use-after-free issues, and guarantee that module fields are initialized before the DP thread can access them.

Changes:

  • Add error checking for DP task initialization to catch creation failures
  • Fix task pointer assignment to only occur on successful initialization
  • Reorder module field initialization to happen before DP thread creation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/schedule/zephyr_dp_schedule_thread.c Modified scheduler_dp_task_init() to defer task pointer assignment until after successful thread creation
src/audio/module_adapter/module_adapter.c Added error handling for DP task creation and moved module field initialization before thread creation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Check the value returned by the pipeline_comp_dp_task_init() call in
module_adapter_new_ext(). Update scheduler_dp_task_init() to assign the
output task structure pointer only on success. The function allocates task
structure and free it on failure. Returning a non-null task on error could
lead to a double free in the module adapter or use after free.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Fix use after free in module_adapter_new_ext() by removing the dst access
after freeing mod. The dst points to a field inside the previously
allocated mod structure. The structure is freed on error so its fields do
not need to be cleared beforehand.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
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.

1 participant