comp: return 0 in data size 0 case in comp_set_model

In comp_set_model() function, when required size is equal to 0,
we should not allocate memory and just return 0.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
Bartosz Kokoszko 2020-06-19 15:15:12 +02:00 committed by Liam Girdwood
parent 998f0a422d
commit dcb185a78c
1 changed files with 6 additions and 3 deletions

View File

@ -341,11 +341,11 @@ void comp_free_model_data(struct comp_dev *dev, struct comp_model_data *model)
int comp_alloc_model_data(struct comp_dev *dev, struct comp_model_data *model,
uint32_t size)
{
comp_free_model_data(dev, model);
if (!size)
return 0;
comp_free_model_data(dev, model);
model->data = rballoc(0, SOF_MEM_CAPS_RAM, size);
if (!model->data) {
@ -376,7 +376,10 @@ int comp_set_model(struct comp_dev *dev, struct comp_model_data *model,
*/
if (!cdata->msg_index) {
ret = comp_alloc_model_data(dev, model, cdata->data->size);
if (ret < 0)
/* in case when required model size is equal to zero we do not
* allocate memory and should just return 0
*/
if (ret < 0 || !cdata->data->size)
return ret;
}