SRC: Add checks for number of channels when initializing from params

This patch prevents SRCs init to loop past PLATFORM_MAX_CHANNELS.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2017-09-22 16:08:44 +03:00 committed by Liam Girdwood
parent efbb97bb05
commit 849a528506
2 changed files with 4 additions and 2 deletions

View File

@ -322,7 +322,7 @@ static int src_params(struct comp_dev *dev)
size_t delay_lines_size;
uint32_t source_rate, sink_rate;
int32_t *buffer_start;
int n = 0, i, err, frames_is_for_source, q;
int n = 0, i, err, frames_is_for_source, nch, q;
trace_src("par");
@ -392,7 +392,8 @@ static int src_params(struct comp_dev *dev)
buffer_start = cd->delay_lines + need.scratch;
/* Initize SRC for actual sample rate */
for (i = 0; i < params->channels; i++) {
nch = MIN(params->channels, PLATFORM_MAX_CHANNELS);
for (i = 0; i < nch; i++) {
n = src_polyphase_init(&cd->src[i], source_rate, sink_rate,
&need, buffer_start);
buffer_start += need.single_src;

View File

@ -33,6 +33,7 @@
#define SRC_CORE_H
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
struct src_alloc {
int fir_s1;