Skip to content

Commit c22187c

Browse files
committed
mux: ipc4: validate channels_count before building mask
build_config() looped over host-supplied channels_count writing streams[].mask[] (size PLATFORM_MAX_CHANNELS), overflowing it. Reject counts above the max. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 3f7738d commit c22187c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/audio/mux/mux_ipc4.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ static int build_config(struct processing_module *mod, struct mux_data *cfg)
3636
{
3737
struct comp_dev *dev = mod->dev;
3838
struct comp_data *cd = module_get_private_data(mod);
39+
uint32_t base_ch = cfg->base_cfg.audio_fmt.channels_count;
40+
uint32_t ref_ch = cfg->reference_format.channels_count;
41+
uint32_t out_ch = cfg->output_format.channels_count;
3942
int mask = 1;
4043
int i;
4144

45+
/* base+reference map 1:1 to contiguous output channels: sink width
46+
* must equal their sum and fit the 8-bit output mask
47+
*/
48+
if (base_ch + ref_ch > PLATFORM_MAX_CHANNELS || out_ch != base_ch + ref_ch) {
49+
comp_err(dev, "invalid channel count: base %u + reference %u -> output %u (max %u)",
50+
base_ch, ref_ch, out_ch, PLATFORM_MAX_CHANNELS);
51+
return -EINVAL;
52+
}
53+
4254
cd->config.num_streams = MUX_MAX_STREAMS;
4355

4456
/* clear masks */

0 commit comments

Comments
 (0)