From: Zhao Dongdong <winter91@foxmail.com>
To: lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com,
daniel.baluta@nxp.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhao Dongdong <zhaodongdong@kylinos.cn>,
stable@vger.kernel.org
Subject: [PATCH v2] ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
Date: Wed, 10 Jun 2026 15:20:43 +0800 [thread overview]
Message-ID: <tencent_3EED6D778DC52C3703A2D1EE8119372E8E08@qq.com> (raw)
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
next reply other threads:[~2026-06-10 7:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 7:20 Zhao Dongdong [this message]
2026-06-10 13:47 ` Péter Ujfalusi
2026-06-11 20:41 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_3EED6D778DC52C3703A2D1EE8119372E8E08@qq.com \
--to=winter91@foxmail.com \
--cc=daniel.baluta@nxp.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=zhaodongdong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®