Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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>

authored by

Li Qiang and committed by
Mark Brown
5726b684 7a37291e

+1 -1
+1 -1
sound/soc/amd/acp/acp-sdw-sof-mach.c
··· 176 176 cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, 177 177 "SDW%d Pin%d", 178 178 link_num, cpu_pin_id); 179 - dev_dbg(dev, "cpu->dai_name:%s\n", cpus->dai_name); 180 179 if (!cpus->dai_name) 181 180 return -ENOMEM; 181 + dev_dbg(dev, "cpu->dai_name:%s\n", cpus->dai_name); 182 182 183 183 codec_maps[j].cpu = 0; 184 184 codec_maps[j].codec = j;