未验证 提交 5661ad94 编写于 作者: K Keyon Jie 提交者: Mark Brown

ASoC: SOF: control: correct the copy size for bytes kcontrol put

The size for the bytes kcontrol should include the abi header, that is,
data->size + sizeof(*data), it is also aligned with get method after
this change.

Fixes: c3078f53 ("ASoC: SOF: Add Sound Open Firmware KControl support")
Reviewed-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NKeyon Jie <yang.jie@linux.intel.com>
Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 fab4edf4
...@@ -349,6 +349,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -349,6 +349,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
struct snd_sof_dev *sdev = scontrol->sdev; struct snd_sof_dev *sdev = scontrol->sdev;
struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
struct sof_abi_hdr *data = cdata->data; struct sof_abi_hdr *data = cdata->data;
size_t size = data->size + sizeof(*data);
int ret, err; int ret, err;
if (be->max > sizeof(ucontrol->value.bytes.data)) { if (be->max > sizeof(ucontrol->value.bytes.data)) {
...@@ -358,10 +359,10 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -358,10 +359,10 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
} }
if (data->size > be->max) { if (size > be->max) {
dev_err_ratelimited(sdev->dev, dev_err_ratelimited(sdev->dev,
"error: size too big %d bytes max is %d\n", "error: size too big %zu bytes max is %d\n",
data->size, be->max); size, be->max);
return -EINVAL; return -EINVAL;
} }
...@@ -375,7 +376,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -375,7 +376,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
} }
/* copy from kcontrol */ /* copy from kcontrol */
memcpy(data, ucontrol->value.bytes.data, data->size); memcpy(data, ucontrol->value.bytes.data, size);
/* notify DSP of byte control updates */ /* notify DSP of byte control updates */
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册