audio: mux: Fix use of incorrect macro#10838
Open
tmleman wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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()withcomp_buffer_get_source_component()when checking pipeline ownership for producer buffers indemux_trigger().
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); |
Contributor
Author
|
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. |
serhiy-katsyuba-intel
approved these changes
Jun 3, 2026
kv2019i
approved these changes
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. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
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.
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.