@@ -1752,15 +1752,15 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index,
return ret;
}
-static size_t sof_get_control_data(struct snd_sof_dev *sdev,
- struct snd_soc_dapm_widget *widget,
- struct sof_widget_data *wdata)
+static int sof_get_control_data(struct snd_sof_dev *sdev,
+ struct snd_soc_dapm_widget *widget,
+ struct sof_widget_data *wdata,
+ size_t *size)
{
const struct snd_kcontrol_new *kc;
struct soc_mixer_control *sm;
struct soc_bytes_ext *sbe;
struct soc_enum *se;
- size_t size = 0;
int i;
for (i = 0; i < widget->num_kcontrols; i++) {
@@ -1800,7 +1800,11 @@ static size_t sof_get_control_data(struct snd_sof_dev *sdev,
if (wdata[i].pdata->magic != SOF_ABI_MAGIC)
return -EINVAL;
- size += wdata[i].pdata->size;
+ /* don't accept 0 size for data */
+ if (!wdata[i].pdata->size)
+ return -EINVAL;
+
+ *size += wdata[i].pdata->size;
/* get data type */
switch (wdata[i].control->cmd) {
@@ -1819,7 +1823,7 @@ static size_t sof_get_control_data(struct snd_sof_dev *sdev,
}
}
- return size;
+ return 0;
}
static int sof_process_load(struct snd_soc_component *scomp, int index,
@@ -1855,12 +1859,11 @@ static int sof_process_load(struct snd_soc_component *scomp, int index,
return -ENOMEM;
/* get possible component controls and get size of all pdata */
- ipc_data_size = sof_get_control_data(sdev, widget, wdata);
+ ret = sof_get_control_data(sdev, widget, wdata,
+ &ipc_data_size);
- if (ipc_data_size <= 0) {
- ret = ipc_data_size;
+ if (ret < 0)
goto out;
- }
}
ipc_size = sizeof(struct sof_ipc_comp_process) +