[Sound-open-firmware] [PATCH] mixer: make sure mixer does not overflow sources.

Liam Girdwood liam.r.girdwood at linux.intel.com
Thu Oct 19 18:33:27 CEST 2017


Add protection to make sure we don't overflow the number of sources.

Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
---
 src/audio/mixer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/audio/mixer.c b/src/audio/mixer.c
index cf265a7..41f1d88 100644
--- a/src/audio/mixer.c
+++ b/src/audio/mixer.c
@@ -233,6 +233,10 @@ static int mixer_copy(struct comp_dev *dev)
 		/* only mix the sources with the same state with mixer */
 		if (source->source->state == dev->state)
 			sources[num_mix_sources++] = source;
+
+		/* too many sources ? */
+		if (num_mix_sources == PLATFORM_MAX_STREAMS - 1)
+			return 0;
 	}
 
 	/* dont have any work if all sources are inactive */
-- 
2.11.0



More information about the Sound-open-firmware mailing list