Re: [alsa-devel] [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component

From: Pierre-Louis Bossart
Date: Fri Jan 11 2019 - 16:49:12 EST



Thanks for the overnight fix. This update fixes the issue on my Skylake XPS13 test device (blind testing since I don't understand what the code does).

Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>

I need to take this back, this set of changes (initial+fix) causes an error with our HDMI support

[ÂÂ 17.437684] sof-audio sof-audio: created machine bxt-pcm512x
[ÂÂ 17.585279] bxt-pcm512x bxt-pcm512x: ASoC: failed to init link iDisp1
[ÂÂ 17.585639] bxt-pcm512x bxt-pcm512x: snd_soc_register_card failed -517

Removing your changes restores the functionality

Adding some traces I can see that the the platform name we use doesn't seem compatible with your logic. All the Intel boards used a constant platform name matching the PCI ID, see e.g. [1], which IIRC is used to bind components. Liam, do you recall in more details if this is really required?

[1] https://elixir.bootlin.com/linux/latest/source/sound/soc/intel/boards/bxt_da7219_max98357a.c#L475

[ÂÂ 18.205812] plb: platform name sof-audio
[ÂÂ 18.206059] plb: cpu_name (null)
[ÂÂ 18.206234] plb: platform name 0000:00:0e.0
[ÂÂ 18.206459] plb: returning -EPROBE_DEFER 1
[ÂÂ 18.206686] bxt-pcm512x bxt-pcm512x: ASoC: failed to init link iDisp1
[ÂÂ 18.207054] bxt-pcm512x bxt-pcm512x: snd_soc_register_card failed -517

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cbafbdd02483..ae731212f82b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1133,11 +1133,15 @@ static int soc_init_dai_link(struct snd_soc_card *card,
ÂÂÂÂÂÂÂÂ * Defer card registration if platform dai component is not added to
ÂÂÂÂÂÂÂÂ * component list.
ÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂ pr_err("plb: platform name %s\n", link->platform->name);
ÂÂÂÂÂÂÂ if (link->platform->of_node || link->platform->name)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (!soc_find_component(link->platform->of_node,
link->platform->name))
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -EPROBE_DEFER;
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ {
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pr_err("plb: returning -EPROBE_DEFER 1\n");
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -EPROBE_DEFER;

+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ }
ÂÂÂÂÂÂÂ /*
ÂÂÂÂÂÂÂÂ * CPU device may be specified by either name or OF node, but
ÂÂÂÂÂÂÂÂ * can be left unspecified, and will be matched based on DAI
@@ -1154,9 +1158,14 @@ static int soc_init_dai_link(struct snd_soc_card *card,
ÂÂÂÂÂÂÂÂ * Defer card registration if cpu dai component is not added to
ÂÂÂÂÂÂÂÂ * component list.
ÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂ pr_err("plb: cpu_name %s\n", link->cpu_name);
ÂÂÂÂÂÂÂ if (link->cpu_of_node || link->cpu_name)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (!soc_find_component(link->cpu_of_node, link->cpu_name))
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -EPROBE_DEFER;
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ {
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pr_err("plb: returning -EPROBE_DEFER 2\n");
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -EPROBE_DEFER;
+
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ }

ÂÂÂÂÂÂÂ /*
ÂÂÂÂÂÂÂÂ * At least one of CPU DAI name or CPU device name/node must be