Skip to content

audio: copier: release DAI endpoints when DAI creation fails - #11580

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/copier/dai/fix/mem_leak
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/copier/dai/fix/mem_leak

Conversation

@tmleman

@tmleman tmleman commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

copier_dai_create() can fail after one or more copier_dai_init() calls succeeded: a later endpoint init can fail, get_converter_func() can find no converter for the host-supplied formats, or the ALH multi-endpoint buffer allocation can fail. These paths returned straight away and copier_init() then only freed the copier private data. Since the copier is never created, copier_free() never runs, so the resources taken by dai_common_new() and dai_config() were leaked: the DAI reference from dai_get(), the DMA reference, the dai_spec_config copy and the DAI group membership. The dai_data itself is reclaimed by the module memory cleanup, which also leaves a dangling entry on the DAI group list.

Unwind with copier_dai_free(), which releases exactly the cd->endpoint_num endpoints that were initialized.

Found with the IPC4 fuzzer: a DAI copier INIT_INSTANCE with a format combination that has no converter leaked three allocations per testcase.

copier_dai_create() can fail after one or more copier_dai_init() calls
succeeded: a later endpoint init can fail, get_converter_func() can
find no converter for the host-supplied formats, or the ALH
multi-endpoint buffer allocation can fail. These paths returned
straight away and copier_init() then only freed the copier private
data. Since the copier is never created, copier_free() never runs, so
the resources taken by dai_common_new() and dai_config() were leaked:
the DAI reference from dai_get(), the DMA reference, the
dai_spec_config copy and the DAI group membership. The dai_data
itself is reclaimed by the module memory cleanup, which also leaves
a dangling entry on the DAI group list.

Unwind with copier_dai_free(), which releases exactly the
cd->endpoint_num endpoints that were initialized.

Found with the IPC4 fuzzer: a DAI copier INIT_INSTANCE with a format
combination that has no converter leaked three allocations per
testcase.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the DAI copier failure-path cleanup changes.

No open issues 🎉

What changed in this PR

This PR fixes resource leaks during DAI copier creation by releasing initialized endpoints when creation fails, before module memory cleanup runs.

Changes:

  • Routes endpoint initialization, converter lookup, and multi-endpoint buffer allocation failures through a shared cleanup path.
  • Reuses copier_dai_free() to release initialized endpoints while preserving the original error code.
File Description
src/​audio/​copier/​copier_dai.c Adds endpoint teardown to DAI copier creation failure paths.

Review effort: Balanced

@intel-sofci

Copy link
Copy Markdown

PR 11580: test results

Run date: 2026-12-01 18:48 UTC

Tested commit: 8f96d4178f4e28f2b4418835879c76aa64cbff37

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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.

4 participants