Commit 4a34613b authored by Yang Yingliang's avatar Yang Yingliang Committed by Mark Brown

ASoC: sigmadsp: switch to use kmemdup_nul() helper

Use kmemdup_nul() helper instead of open-coding to
simplify the code.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220825123525.1845695-1-yangyingliang@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fcc245c6
...@@ -227,13 +227,11 @@ static int sigma_fw_load_control(struct sigmadsp *sigmadsp, ...@@ -227,13 +227,11 @@ static int sigma_fw_load_control(struct sigmadsp *sigmadsp,
if (!ctrl) if (!ctrl)
return -ENOMEM; return -ENOMEM;
name = kzalloc(name_len + 1, GFP_KERNEL); name = kmemdup_nul(ctrl_chunk->name, name_len, GFP_KERNEL);
if (!name) { if (!name) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_free_ctrl; goto err_free_ctrl;
} }
memcpy(name, ctrl_chunk->name, name_len);
name[name_len] = '\0';
ctrl->name = name; ctrl->name = name;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment