ASoC: skl-topology: Use kmemdup to replace kzalloc + memcpy
authorzhong jiang <zhongjiang@huawei.com>
Sat, 8 Sep 2018 08:36:20 +0000 (16:36 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 10 Sep 2018 14:20:20 +0000 (15:20 +0100)
kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to kmemdup rather than the open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-topology.c

index 2620d77729c52edf06dd4d347825b9872b9070da..52a9915da0f5cccf2cf82d242960d5dc15bc1e58 100644 (file)
@@ -898,11 +898,10 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
                        bc = (struct skl_algo_data *)sb->dobj.private;
 
                        if (bc->set_params == SKL_PARAM_BIND) {
-                               params = kzalloc(bc->max, GFP_KERNEL);
+                               params = kmemdup(bc->params, bc->max, GFP_KERNEL);
                                if (!params)
                                        return -ENOMEM;
 
-                               memcpy(params, bc->params, bc->max);
                                skl_fill_sink_instance_id(ctx, params, bc->max,
                                                                mconfig);