Skip to content

audio: mux: Fix use of incorrect macro#10838

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/mux/fix_overrun
Open

audio: mux: Fix use of incorrect macro#10838
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/mux/fix_overrun

Conversation

@tmleman
Copy link
Copy Markdown
Contributor

@tmleman tmleman commented Jun 3, 2026

comp_buffer_get_sink_component(b) inside a for_each_producer loop returns mux itself, making the pipeline comparison always false and audio_stream_set_overrun() unreachable.

Issue found using semgrep with custom rules.

@tmleman tmleman requested a review from fkwasowi as a code owner June 3, 2026 15:20
Copilot AI review requested due to automatic review settings June 3, 2026 15:20
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 fixes a logic error in the DEMUX pre-start trigger path where the wrong buffer-component accessor prevented the cross-pipeline comparison from ever succeeding, making audio_stream_set_overrun() unreachable.

Changes:

  • Replace comp_buffer_get_sink_component() with comp_buffer_get_source_component() when checking pipeline ownership for producer buffers in demux_trigger().

Comment thread src/audio/mux/mux.c
Comment on lines 294 to 296
comp_dev_for_each_producer(mod->dev, b) {
if (comp_buffer_get_sink_component(b)->pipeline != mod->dev->pipeline)
if (comp_buffer_get_source_component(b)->pipeline != mod->dev->pipeline)
audio_stream_set_overrun(&b->stream, true);
@tmleman
Copy link
Copy Markdown
Contributor Author

tmleman commented Jun 3, 2026

I'm developing (with the help of AI) custom semgrep rules that will detect incorrect use of macros (mostly related to sink/source api). This PR is fixing one (and only) finding in current code. Here is scan result:

┌────────────────┐
│ 1 Code Finding │
└────────────────┘

    src/audio/mux/mux.c
   ❯❯❱ scripts.scan.semgrep.sof-producer-loop-wrong-component-getter
          ❰❰ Blocking ❱❱
          comp_buffer_get_sink_component() called on producer buffer 'b' inside a comp_dev_for_each_producer
          loop. In this loop, dev is buf->source, so get_sink_component(b) returns dev itself — not the
          upstream neighbour. Use comp_buffer_get_source_component(b) instead.

          295┆ if (comp_buffer_get_sink_component(b)->pipeline != mod->dev->pipeline)

@lyakh @softwarecki can you help review and verify that scan is working correctly.

comp_buffer_get_sink_component(b) inside a for_each_producer loop
returns mux itself, making the pipeline comparison always false and
audio_stream_set_overrun() unreachable.

Issue found using semgrep with custom rules.

Signed-off-by: Tomasz Leman <tomasz.m.leman@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.

4 participants