Skip to content

Commit 9ec9941

Browse files
committed
audio: copier: validate channels_count in copier_set_gain
channels is host-controlled (8-bit, 0-255). Without validation it drives the memcpy length (channels * sizeof(uint16_t)) against a MAX_GAIN_COEFFS_CNT-sized stack buffer and, for channels == 0, causes divide-by-zero in the coefficient replication loop. Reject values outside [1, MAX_GAIN_COEFFS_CNT]. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 3f7738d commit 9ec9941

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/audio/copier/copier_gain.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ int copier_set_gain(struct comp_dev *dev, struct copier_gain_params *gain_params
172172
return -EINVAL;
173173
}
174174

175+
if (channels <= 0 || channels > MAX_GAIN_COEFFS_CNT) {
176+
comp_err(dev, "invalid channels count %d", channels);
177+
return -EINVAL;
178+
}
179+
175180
/* Set gain coefficients */
176181
comp_info(dev, "Update gain coefficients from DMA_CONTROL ipc");
177182

0 commit comments

Comments
 (0)