From b54c14934fe1e4528f44d44d29e1e76cd2293102 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Wed, 7 Oct 2026 13:50:19 +0200 Subject: [PATCH] module: mux: fix dead source check in demux_process The guard read "sources == NULL && sources[0] == NULL". mod->sources is a fixed array inside struct processing_module, so the array argument decays to a non-NULL address and the first operand is always false. The condition is therefore tautologically false and the intended check never runs. struct processing_module is memset to zero on allocation, so with no source bound sources[0] is NULL and the function falls through to source_get_data_frames_available(NULL). Check num_of_sources instead of probing sources[0]. The count is the authoritative indication of whether a source is connected, whereas a NULL sources[0] only reflects the zeroed allocation. This also matches mux_process() in the same file and the guards used by copier, volume, rtnr and dts. The separate num_of_sinks test is folded into the same condition. Note: clang-analyzer-core.NullDereference reported this as a deref of a NULL sources array; that path is unreachable because sources can never be NULL. The defect is the dead check, not the reported deref. Assisted-by: Copilot:claude-opus-5 clang-tidy Signed-off-by: Tomasz Leman --- src/audio/mux/mux.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index 164e690ae906..999471ced771 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -245,15 +245,12 @@ static int demux_process(struct processing_module *mod, comp_dbg(dev, "entry"); - if (sources == NULL && sources[0] == NULL) { + /* if there are no sources or sinks active, then there is nothing to do */ + if (num_of_sources == 0 || num_of_sinks == 0) { return 0; } - source = sources[0]; - /* if there are no sinks active, then there is nothing to do */ - if (num_of_sinks == 0) { - return 0; - } + source = sources[0]; /* the same number of frames is distributed to every sink, so it is * limited by both the source availability and every active sink's free