Skip to content

Commit 18fbe80

Browse files
xiongzhongjiangbroonie
authored andcommitted
ASoC: q6core: Use kmemdup to replace kzalloc + memcpy
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>
1 parent fb77436 commit 18fbe80

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

sound/soc/qcom/qdsp6/q6core.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
105105
bytes = sizeof(*fwk) + fwk->num_services *
106106
sizeof(fwk->svc_api_info[0]);
107107

108-
core->fwk_version = kzalloc(bytes, GFP_ATOMIC);
108+
core->fwk_version = kmemdup(data->payload, bytes, GFP_ATOMIC);
109109
if (!core->fwk_version)
110110
return -ENOMEM;
111111

112-
memcpy(core->fwk_version, data->payload, bytes);
113-
114112
core->fwk_version_supported = true;
115113
core->resp_received = true;
116114

@@ -124,12 +122,10 @@ static int q6core_callback(struct apr_device *adev, struct apr_resp_pkt *data)
124122

125123
len = sizeof(*v) + v->num_services * sizeof(v->svc_api_info[0]);
126124

127-
core->svc_version = kzalloc(len, GFP_ATOMIC);
125+
core->svc_version = kmemdup(data->payload, len, GFP_ATOMIC);
128126
if (!core->svc_version)
129127
return -ENOMEM;
130128

131-
memcpy(core->svc_version, data->payload, len);
132-
133129
core->get_version_supported = true;
134130
core->resp_received = true;
135131

0 commit comments

Comments
 (0)