]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: q6core: Use kmemdup to replace kzalloc + memcpy
authorzhong jiang <zhongjiang@huawei.com>
Sat, 8 Sep 2018 08:36:19 +0000 (16:36 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 10 Sep 2018 14:20:16 +0000 (15:20 +0100)
kmemdup has implemented the function that kzalloc() + memcpy() will
do. and we prefer to use the 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/qcom/qdsp6/q6core.c

index 06f03a5fe9bd70e07b74343c63e93e5f1f50d309..ca1be7305524d5da393cfdf015ea821e188641e8 100644 (file)
@@ -105,12 +105,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
                bytes = sizeof(*fwk) + fwk->num_services *
                                sizeof(fwk->svc_api_info[0]);
 
-               core->fwk_version = kzalloc(bytes, GFP_ATOMIC);
+               core->fwk_version = kmemdup(data->payload, bytes, GFP_ATOMIC);
                if (!core->fwk_version)
                        return -ENOMEM;
 
-               memcpy(core->fwk_version, data->payload, bytes);
-
                core->fwk_version_supported = true;
                core->resp_received = true;
 
@@ -124,12 +122,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
 
                len = sizeof(*v) + v->num_services * sizeof(v->svc_api_info[0]);
 
-               core->svc_version = kzalloc(len, GFP_ATOMIC);
+               core->svc_version = kmemdup(data->payload, len, GFP_ATOMIC);
                if (!core->svc_version)
                        return -ENOMEM;
 
-               memcpy(core->svc_version, data->payload, len);
-
                core->get_version_supported = true;
                core->resp_received = true;