ASoC: topology: use kmemdup rather than duplicating its implementation
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 7 Aug 2015 07:59:37 +0000 (09:59 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 7 Aug 2015 12:27:51 +0000 (13:27 +0100)
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-topology.c

index f038c6ef80055344cc1e0e38584d3698f89ec05d..8620dbf410c6cfebe83c49094f804290b389384e 100644 (file)
@@ -832,12 +832,12 @@ static int soc_tplg_denum_create_values(struct soc_enum *se,
        if (ec->items > sizeof(*ec->values))
                return -EINVAL;
 
-       se->dobj.control.dvalues =
-               kmalloc(ec->items * sizeof(u32), GFP_KERNEL);
+       se->dobj.control.dvalues = kmemdup(ec->values,
+                                          ec->items * sizeof(u32),
+                                          GFP_KERNEL);
        if (!se->dobj.control.dvalues)
                return -ENOMEM;
 
-       memcpy(se->dobj.control.dvalues, ec->values, ec->items * sizeof(u32));
        return 0;
 }