]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: amd: acp-sdw-legacy: check CPU DAI name before logging
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Mon, 11 May 2026 16:42:02 +0000 (13:42 -0300)
committerMark Brown <broonie@kernel.org>
Sat, 16 May 2026 02:24:58 +0000 (11:24 +0900)
devm_kasprintf() can fail and return NULL. The legacy AMD SoundWire
machine driver logs cpus->dai_name before checking the allocation result.

Move the debug print after the NULL check, matching the ordering used by
the SOF AMD SoundWire path after commit 5726b68473f7 ("ASoC: amd/sdw_utils:
avoid NULL deref when devm_kasprintf() fails").

Fixes: 2981d9b0789c ("ASoC: amd: acp: add soundwire machine driver for legacy stack")
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260511-asoc-amd-acp-sdw-legacy-dai-name-null-v1-1-dc6151b6da8a@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/amd/acp/acp-sdw-legacy-mach.c

index 0f21e5f64531a211d8f16b7241f13c976ff6916f..09b475c83c4966a3094ad788abd9477b3f60ae4f 100644 (file)
@@ -260,9 +260,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;