Skip to contentSkip to conversation

ASoC: SOF: topology: Fix mem leak in sof_dai_load()

PATCH In review Kamil Duljas 3 participants 3 messages Nov 16, 2023 – Nov 17, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: SOF: topology: Fix mem leak in sof_dai_load()

The function has multiple return points at which it is not released previously allocated memory.

---
Changes in v2: removed wrong usages of kfree

---
 sound/soc/sof/topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/sof/topology.c +3 -1
index a3a3af252259..37ec671a2d76 100644
@@ -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;
Signature · 1 line
2.42.0.windows.2
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 2 lines · Kamil Duljas

The function has multiple return points at which it is not released previously allocated memory.

Quoted 23 lines

---
Changes in v2: removed wrong usages of kfree

---
 sound/soc/sof/topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/sof/topology.c +3 -1
index a3a3af252259..37ec671a2d76 100644
@@ -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;
Signature · 1 line
Péter
maintainer
#2 lore raw
In reply to Kamil Duljas
Quoted 4 lines · Kamil Duljas

The function has multiple return points at which it is not released previously allocated memory.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

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

      commit: 31e721fbd194d5723722eaa21df1d14cee7e12b5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark