summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Qiang <liqiang01@kylinos.cn>2025-10-15 15:55:30 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-23 16:20:37 +0200
commit095d692e5997ece300c89f10d903d5230090e6a0 (patch)
treee3a28193f71c55a485b3237be350a116d8162d34
parent9ab3e03765b93679aafeef6c0302b6a4c1f27623 (diff)
downloadlinux-095d692e5997ece300c89f10d903d5230090e6a0.tar.gz
linux-095d692e5997ece300c89f10d903d5230090e6a0.tar.bz2
linux-095d692e5997ece300c89f10d903d5230090e6a0.zip
ASoC: amd/sdw_utils: avoid NULL deref when devm_kasprintf() fails
[ Upstream commit 5726b68473f7153a7f6294185e5998b7e2a230a2 ] devm_kasprintf() may return NULL on memory allocation failure, but the debug message prints cpus->dai_name before checking it. Move the dev_dbg() call after the NULL check to prevent potential NULL pointer dereference. Fixes: cb8ea62e64020 ("ASoC: amd/sdw_utils: add sof based soundwire generic machine driver") Signed-off-by: Li Qiang <liqiang01@kylinos.cn> Link: https://patch.msgid.link/20251015075530.146851-1-liqiang01@kylinos.cn Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--sound/soc/amd/acp/acp-sdw-sof-mach.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/soc/amd/acp/acp-sdw-sof-mach.c b/sound/soc/amd/acp/acp-sdw-sof-mach.c
index 99a244f495bd..876f0b7fcd3d 100644
--- a/sound/soc/amd/acp/acp-sdw-sof-mach.c
+++ b/sound/soc/amd/acp/acp-sdw-sof-mach.c
@@ -216,9 +216,9 @@ static int create_sdw_dailink(struct snd_soc_card *card,
cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SDW%d Pin%d",
link_num, cpu_pin_id);
- dev_dbg(dev, "cpu->dai_name:%s\n", cpus->dai_name);
if (!cpus->dai_name)
return -ENOMEM;
+ dev_dbg(dev, "cpu->dai_name:%s\n", cpus->dai_name);
codec_maps[j].cpu = 0;
codec_maps[j].codec = j;