[PATCH] ASoC: topology: Add missing memory checks

Amadeusz Sławiński amadeuszx.slawinski at linux.intel.com
Fri Mar 27 19:16:54 CET 2020


On 3/21/2020 1:18 AM, Ranjani Sridharan wrote:

(...)

>>   	if (pcm->compress)
>> @@ -1835,11 +1849,7 @@ static int soc_tplg_dai_create(struct soc_tplg
>> *tplg,
>>   	ret = soc_tplg_dai_load(tplg, dai_drv, pcm, NULL);
>>   	if (ret < 0) {
>>   		dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
>> -		kfree(dai_drv->playback.stream_name);
>> -		kfree(dai_drv->capture.stream_name);
>> -		kfree(dai_drv->name);
>> -		kfree(dai_drv);
>> -		return ret;
>> +		goto err;
>>   	}
>>   
>>   	dai_drv->dobj.index = tplg->index;
>> @@ -1857,9 +1867,17 @@ static int soc_tplg_dai_create(struct soc_tplg
>> *tplg,
>>   	if (ret != 0) {
>>   		dev_err(dai->dev, "Failed to create DAI widgets %d\n",
>> ret);
>>   		snd_soc_unregister_dai(dai);
>> -		return ret;
>> +		goto err;
> Hi Amadeusz,
> 
> I think this is not needed. Once the dai_drv is added to the dobj_list,
> upon a failure here, the tplg components will be removed and this will
> be taken care of. So it is safe to just return ret here.

Hi,
you are right will do in v2.

(...)
>>   
>>   	if (d->capture) {
>>   		stream = &dai_drv->capture;
>>   		caps = &d->caps[SND_SOC_TPLG_STREAM_CAPTURE];
>> -		set_stream_info(stream, caps);
>> +		ret = set_stream_info(stream, caps);
>> +		if (ret < 0)
>> +			goto err;
>>   	}
>>   
>>   	if (d->flag_mask)
>> @@ -2454,10 +2485,16 @@ static int soc_tplg_dai_config(struct
>> soc_tplg *tplg,
> The return value of soc_tplg_dai_config() in soc_tplg_dai_elems_load()
> is never checked. So maybe we need a follow-up patch to fix that too?
> 

Yes, actually there is few more functions where status is not checked, 
will add checks for them too.

Amadeusz


More information about the Alsa-devel mailing list