diff mbox series

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

Message ID 20201210152541.191728-2-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State Accepted
Commit f5824e5ce1cdba523a357a4d3ffbe0876a27330f
Headers show
Series [1/2] ASoC: topology: Fix wrong size check | expand

Commit Message

Amadeusz Sławiński Dec. 10, 2020, 3:25 p.m. UTC
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>
---
 sound/soc/soc-topology.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ranjani Sridharan Dec. 10, 2020, 5:07 p.m. UTC | #1
On Thu, 2020-12-10 at 10:25 -0500, Amadeusz Sławiński wrote:
> 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>
Both patches look good, Amadeusz!

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
diff mbox series

Patch

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)