Skip to content

Commit e7b9dbe

Browse files
committed
audio: module_adapter: bound host channels_count at ipc4 init
Reject 0 or > PLATFORM_MAX_CHANNELS before modules index channel-sized arrays. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 3f7738d commit e7b9dbe

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ int module_adapter_init_data(struct comp_dev *dev,
155155
dst->base_cfg = cfg->base_cfg;
156156
dst->size = cfgsz;
157157

158+
/* Host-supplied channel count indexes PLATFORM_MAX_CHANNELS arrays. */
159+
if (dst->base_cfg.audio_fmt.channels_count == 0 ||
160+
dst->base_cfg.audio_fmt.channels_count > PLATFORM_MAX_CHANNELS) {
161+
comp_err(dev, "invalid channels count %u",
162+
dst->base_cfg.audio_fmt.channels_count);
163+
return -EINVAL;
164+
}
165+
158166
if (cfgsz >= sizeof(*cfg)) {
159167
int n_in = cfg->base_cfg_ext.nb_input_pins;
160168
int n_out = cfg->base_cfg_ext.nb_output_pins;

0 commit comments

Comments
 (0)