Skip to content

Commit ccce7d6

Browse files
committed
smart_amp_test: bound channel counts to platform max
The sample component took its channel counts from the streams and used them to index the platform-sized channel map without bounds. Reject counts above the platform maximum. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 9105ea4 commit ccce7d6

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/samples/audio/smart_amp_test_ipc3.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,16 @@ static int smart_amp_prepare(struct comp_dev *dev)
518518

519519
sad->in_channels = audio_stream_get_channels(&sad->source_buf->stream);
520520

521+
/* out_channels bounds the processing loop that indexes the
522+
* PLATFORM_MAX_CHANNELS-sized channel map, so reject a larger count
523+
*/
524+
if (sad->out_channels > PLATFORM_MAX_CHANNELS ||
525+
sad->in_channels > PLATFORM_MAX_CHANNELS) {
526+
comp_err(dev, "invalid channel count, in %u out %u",
527+
sad->in_channels, sad->out_channels);
528+
return -EINVAL;
529+
}
530+
521531
if (sad->feedback_buf) {
522532
audio_stream_set_channels(&sad->feedback_buf->stream,
523533
sad->config.feedback_channels);

0 commit comments

Comments
 (0)