Unverified Commit 5726b684 authored by Li Qiang's avatar Li Qiang Committed by Mark Brown
Browse files

ASoC: amd/sdw_utils: avoid NULL deref when devm_kasprintf() fails



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: cb8ea62e ("ASoC: amd/sdw_utils: add sof based soundwire generic machine driver")
Signed-off-by: default avatarLi Qiang <liqiang01@kylinos.cn>
Link: https://patch.msgid.link/20251015075530.146851-1-liqiang01@kylinos.cn


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7a37291e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -176,9 +176,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;