ASoC: topology: Add missing size check
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Thu, 10 Dec 2020 15:25:41 +0000 (10:25 -0500)
committerMark Brown <broonie@kernel.org>
Fri, 11 Dec 2020 13:23:00 +0000 (13:23 +0000)
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@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20201210152541.191728-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-topology.c

index eb2633dd645498d7af798c4bef1a2ca8f7a11bc3..e85b52798bc54f5148ce8efc49485c5bfc554cfa 100644 (file)
@@ -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)