* [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
@ 2026-06-10 7:20 Zhao Dongdong
2026-06-10 13:47 ` Péter Ujfalusi
2026-06-11 20:41 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Zhao Dongdong @ 2026-06-10 7:20 UTC (permalink / raw)
To: lgirdwood, peter.ujfalusi, daniel.baluta
Cc: linux-sound, linux-kernel, Zhao Dongdong, stable
From: Zhao Dongdong <zhaodongdong@kylinos.cn>
When the topology filename contains "dummy" and tplg_cnt is 0, the
function returns -EINVAL directly without freeing the tplg_files
allocated by kcalloc() at line 2497. This leaks memory on every
such topology load attempt.
Fix this by setting ret = -EINVAL and jumping to the out: label,
which already handles the kfree(tplg_files) cleanup.
Fixes: 99c159279c6d ("ASoC: SOF: don't check the existence of dummy topology")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
---
v2: add kfree(tplg_files) before the return
v1: https://lore.kernel.org/all/tencent_D87B6446BC0B517BEF9D4731C6CD8B288206@qq.com/
---
sound/soc/sof/topology.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 63d582c65891..a368e257c459 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -2534,6 +2534,8 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
if (strstr(file, "dummy")) {
dev_err(scomp->dev,
"Function topology is required, please upgrade sof-firmware\n");
+
+ kfree(tplg_files);
return -EINVAL;
}
tplg_files[0] = file;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
2026-06-10 7:20 [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology Zhao Dongdong
@ 2026-06-10 13:47 ` Péter Ujfalusi
2026-06-11 20:41 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Péter Ujfalusi @ 2026-06-10 13:47 UTC (permalink / raw)
To: Zhao Dongdong, lgirdwood, daniel.baluta
Cc: linux-sound, linux-kernel, Zhao Dongdong, stable
On 10/06/2026 10:20, Zhao Dongdong wrote:
> From: Zhao Dongdong <zhaodongdong@kylinos.cn>
>
> When the topology filename contains "dummy" and tplg_cnt is 0, the
> function returns -EINVAL directly without freeing the tplg_files
> allocated by kcalloc() at line 2497. This leaks memory on every
> such topology load attempt.
>
> Fix this by setting ret = -EINVAL and jumping to the out: label,
> which already handles the kfree(tplg_files) cleanup.
>
> Fixes: 99c159279c6d ("ASoC: SOF: don't check the existence of dummy topology")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> ---
> v2: add kfree(tplg_files) before the return
> v1: https://lore.kernel.org/all/tencent_D87B6446BC0B517BEF9D4731C6CD8B288206@qq.com/
> ---
> sound/soc/sof/topology.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index 63d582c65891..a368e257c459 100644
> --- a/sound/soc/sof/topology.c
> +++ b/sound/soc/sof/topology.c
> @@ -2534,6 +2534,8 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
> if (strstr(file, "dummy")) {
> dev_err(scomp->dev,
> "Function topology is required, please upgrade sof-firmware\n");
> +
> + kfree(tplg_files);
> return -EINVAL;
> }
> tplg_files[0] = file;
--
Péter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
2026-06-10 7:20 [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology Zhao Dongdong
2026-06-10 13:47 ` Péter Ujfalusi
@ 2026-06-11 20:41 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-06-11 20:41 UTC (permalink / raw)
To: lgirdwood, peter.ujfalusi, daniel.baluta, Zhao Dongdong
Cc: linux-sound, linux-kernel, Zhao Dongdong, stable
On Wed, 10 Jun 2026 15:20:43 +0800, Zhao Dongdong wrote:
> ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
https://git.kernel.org/broonie/sound/c/d46f9f238972
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-12 22:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 7:20 [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology Zhao Dongdong
2026-06-10 13:47 ` Péter Ujfalusi
2026-06-11 20:41 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®