Skip to contentSkip to conversation

ALSA: aw2-alsa: select SND_PCM

PATCH In review Jude Gyimah 2 participants 3 messages Nov 13 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: aw2-alsa: select SND_PCM

Several stanzas in sound/pci/Kconfig select SND_PCM. SND_AW2 selects nothing at all.

aw2-alsa calls snd_pcm_new, which sound/core/pcm.c provides under SND_PCM.

aw2-alsa.c:(.text+0x554): undefined reference to `snd_pcm_new'

4 symbols are undefined in all.

The driver can be built into vmlinux while SND_PCM is a module, in which case the symbols are not there at link time.

Select rather than depend on: SND_PCM has no prompt of its own and is only ever enabled by a select, so a depends on would leave SND_AW2 unselectable.

Reproduced on v7.3, arm64, with CONFIG_SND_AW2=y and CONFIG_SND_PCM=m.

Found with kreach, a static check that compares what Kconfig allows against the symbols the compiled objects actually reference.

Fixes 98f2a97f207a ("[ALSA] Emagic Audiowerk 2 ALSA driver.")
---
 sound/pci/Kconfig | 1 +
 1 file changed, 1 insertion(+)
sound/pci/Kconfig +1 -0
index 6366f72b3667..9c192d51ff44 100644
@@ -141,6 +141,7 @@ config SND_AU8830
 
 config SND_AW2
 	tristate "Emagic Audiowerk 2"
+	select SND_PCM
 	help
 	  Say Y here to include support for Emagic Audiowerk 2 soundcards.
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 17 lines · Jude Gyimah

Several stanzas in sound/pci/Kconfig select SND_PCM. SND_AW2 selects nothing at all.

aw2-alsa calls snd_pcm_new, which sound/core/pcm.c provides under SND_PCM.

aw2-alsa.c:(.text+0x554): undefined reference to `snd_pcm_new'

4 symbols are undefined in all.

The driver can be built into vmlinux while SND_PCM is a module, in which case the symbols are not there at link time.

Select rather than depend on: SND_PCM has no prompt of its own and is only ever enabled by a select, so a depends on would leave SND_AW2 unselectable.

Quoted 7 lines

Reproduced on v7.3, arm64, with CONFIG_SND_AW2=y and CONFIG_SND_PCM=m.

Found with kreach, a static check that compares what Kconfig allows against the symbols the compiled objects actually reference.

Fixes 98f2a97f207a ("[ALSA] Emagic Audiowerk 2 ALSA driver.")

Applied now. It's interesting why this wasn't caught by build tests for long time...

thanks,

Takashi

#2 lore raw
Quoted 2 lines

Applied now. It's interesting why this wasn't caught by build tests for long time...

Thanks for applying it.

Yes i agree. Quite interesting that this flew under the radar. The short answer is that none of the stock configurations can express the combination, and each one misses it for a different reason. On arm64 at v7.3:

  defconfig       SND_AW2 not set     SND_PCM=m   caller absent
  allmodconfig    SND_AW2=m           SND_PCM=m   caller is a module too
  allyesconfig    SND_AW2=y           SND_PCM=y   provider built in
  allnoconfig     neither set

The failure needs SND_AW2=y while SND_PCM=m, and allmodconfig and allyesconfig are each wrong in exactly one coordinate.

randconfig can express it but is unlikely to find it. And the reason is kinda counter-intuitive i.e., 110 stanzas in 44 Kconfig files select SND_PCM. Any one of them at =y pins SND_PCM=y and hides every caller that does not select it. So the configuration has to put all 110 at m or n and this driver at y. Treating the tristates as independent and uniform (which randconfig and tristates are not, since most sit behind PCI or a platform) that is on the order of (2/3)^110. The real figure will be different, but the shape is right. The more drivers select a provider, the better hidden the one driver that forgot to.

So SND_PCM being selected by almost everything is what protected this bug rather than what would have exposed it. A sampler would have to be lucky in 110 places at once. Solving for the assignment instead takes it in one step, which is what turned this up.

It is not a one-off. The same y/m shape found 14 missing selects in sound/, all of them now applied i.e., five Rockchip, three fsl, sunxi, four Amlogic, and this. Reproducer configurations and the failing vmlinux link log for each are published at
https://github.com/JGyimah/kreach under results/, if the ALSA side is ever interested in running it over sound/ before a merge window.

Best,
Jude