[PATCH 2/2] ASoC: topology: Add missing size check

Amadeusz Sławiński amadeuszx.slawinski at linux.intel.com
Thu Dec 10 16:25:41 CET 2020


When we parse "values" we perform check if there is correct number of
them. However similar check is missing in case of "texts", add it.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski at linux.intel.com>
---
 sound/soc/soc-topology.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 7fb3a87ab860..950c45008e24 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -856,6 +856,9 @@ static int soc_tplg_denum_create_texts(struct soc_tplg *tplg, struct soc_enum *s
 {
 	int i, ret;
 
+	if (le32_to_cpu(ec->items) > ARRAY_SIZE(ec->texts))
+		return -EINVAL;
+
 	se->dobj.control.dtexts =
 		devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), sizeof(char *), GFP_KERNEL);
 	if (se->dobj.control.dtexts == NULL)
-- 
2.25.1



More information about the Alsa-devel mailing list