]> git.itanic.dy.fi Git - linux-stable/commitdiff
ASoC: topology: Fix memory corruption in soc_tplg_denum_create_values()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 20 Jan 2021 09:59:13 +0000 (12:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Feb 2021 22:28:51 +0000 (23:28 +0100)
commit 543466ef3571069b8eb13a8ff7c7cfc8d8a75c43 upstream.

The allocation uses sizeof(u32) when it should use sizeof(unsigned long)
so it leads to memory corruption later in the function when the data is
initialized.

Fixes: 5aebe7c7f9c2 ("ASoC: topology: fix endianness issues")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YAf+8QZoOv+ct526@mwanda
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/soc-topology.c

index 42e1a9beaf3f5b2ed79d1efca5280a8864a44a48..1030e11017b2746527377daba04b5d737be08371 100644 (file)
@@ -987,7 +987,7 @@ static int soc_tplg_denum_create_values(struct soc_enum *se,
                return -EINVAL;
 
        se->dobj.control.dvalues = kzalloc(le32_to_cpu(ec->items) *
-                                          sizeof(u32),
+                                          sizeof(*se->dobj.control.dvalues),
                                           GFP_KERNEL);
        if (!se->dobj.control.dvalues)
                return -ENOMEM;