diff mbox series

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

Message ID 20231116213926.2034-2-kamil.duljas@gmail.com
State Accepted
Commit 31e721fbd194d5723722eaa21df1d14cee7e12b5
Headers show
Series [v2] ASoC: SOF: topology: Fix mem leak in sof_dai_load() | expand

Commit Message

Kamil Duljas Nov. 16, 2023, 9:39 p.m. UTC
The function has multiple return points at which it is not released
previously allocated memory.

Signed-off-by: Kamil Duljas <kamil.duljas@gmail.com>
---
Changes in v2: removed wrong usages of kfree
---
 sound/soc/sof/topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Peter Ujfalusi Nov. 17, 2023, 11:56 a.m. UTC | #1
On 16/11/2023 23:39, Kamil Duljas wrote:
> The function has multiple return points at which it is not released
> previously allocated memory.

Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

> Signed-off-by: Kamil Duljas <kamil.duljas@gmail.com>
> ---
> Changes in v2: removed wrong usages of kfree
> ---
>  sound/soc/sof/topology.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index a3a3af252259..37ec671a2d76 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;
> +		}
>  	}
>  
>  	dai_drv->dobj.private = spcm;
diff mbox series

Patch

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index a3a3af252259..37ec671a2d76 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;
+		}
 	}
 
 	dai_drv->dobj.private = spcm;