Re: [PATCH] ASoC: SOF: topology: Fix mem leak in sof_dai_load()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2023-11-16 at 14:28 +0100, Kamil Duljas wrote:
> The function has multiple return points at which it is not released
> previously allocated memory.
> 
> Signed-off-by: Kamil Duljas <kamil.duljas@xxxxxxxxx>
> ---
>  sound/soc/sof/topology.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index a3a3af252259..ef8f8991f025 100644
> --- a/sound/soc/sof/topology.c
> +++ b/sound/soc/sof/topology.c
> @@ -1736,8 +1736,10 @@ static int sof_dai_load(struct
> snd_soc_component *scomp, int index,
>  	/* perform pcm set op */
>  	if (ipc_pcm_ops && ipc_pcm_ops->pcm_setup) {
>  		ret = ipc_pcm_ops->pcm_setup(sdev, spcm);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			kfree(spcm);
>  			return ret;
> +		}

Thanks for the patch, Kamil. I think just the change above should
suffice to fix the memory leak in case of error. For all the other
error paths below, snd_soc_tplg_component_remove() should be able to
handle freeing the spcm and the page tables.

Thanks,
Ranjani	




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux