]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: SOF: topology: Use kmemdup() to replace kzalloc + memcpy
authorYihao Han <hanyihao@vivo.com>
Thu, 17 Mar 2022 09:38:41 +0000 (02:38 -0700)
committerMark Brown <broonie@kernel.org>
Thu, 17 Mar 2022 17:56:33 +0000 (17:56 +0000)
fix memdup.cocci warning:
sound/soc/sof/topology.c:876:19-26: WARNING opportunity for kmemdup

Generated by: scripts/coccinelle/api/memdup.cocci

Signed-off-by: Yihao Han <hanyihao@vivo.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220317093841.3414-1-hanyihao@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/topology.c

index 367fbe2d5b317d85f531ead7af454f6c274a3615..369693cc6d10ca1d1c99dd3f5ee4c122a196a9ee 100644 (file)
@@ -873,11 +873,10 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp,
 
        /* copy the private data */
        if (priv_size > 0) {
-               scontrol->priv = kzalloc(priv_size, GFP_KERNEL);
+               scontrol->priv = kmemdup(control->priv.data, priv_size, GFP_KERNEL);
                if (!scontrol->priv)
                        return -ENOMEM;
 
-               memcpy(scontrol->priv, control->priv.data, priv_size);
                scontrol->priv_size = priv_size;
        }