linux-IllusionX/sound
Kai Vehmanen 163cd1059a
ASoC: hdac: make SOF HDA codec driver probe deterministic
To provide backward compatibility to older systems, the SOF HDA driver
allows user to specify which HDMI codec driver to use at runtime via
kernel parameter. This mechanism has a subtle flaw in that it assumes
the codec drivers not to be loaded when the SOF PCI driver is loaded.

The problem is rooted in use of the hdev->type field.
snd_hdac_ext_bus_device_init() initializes this field to HDA_DEV_ASOC.
This signals the HDA core that ASoC drivers should be considered in
driver matching (hda_bus_match()). The SOF and SST drivers continue by
overriding this field to HDA_DEV_LEGACY and proceeding to load driver
modules with request_module(). Correct drivers will get loaded and
attached.

If however the codec drivers are already loaded when
snd_hdac_ext_bus_device_init() is called, the matching will not work as
expected as device type is still set to HDA_DEV_ASOC. Specifically if
hdac-hdmi is attached when machine driver is configured to use hdac-hda,
this leads to out-of-bounds memory access in
hda_dsp_hdmi_build_controls().

Fix the issue by adding codec type as a parameter to
snd_hdac_ext_bus_device_init() and ensuring type is set correctly from
the start.

Fixes: 139c7febad ("ASoC: SOF: Intel: add support for snd-hda-codec-hdmi")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200921100841.2882662-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-21 23:57:24 +01:00
..
ac97
aoa
arm
atmel
core ALSA: core: convert tasklets to use new tasklet_setup() API 2020-09-02 13:23:52 +02:00
drivers
firewire ALSA: firewire: convert tasklets to use new tasklet_setup() API 2020-09-02 13:24:14 +02:00
hda ASoC: hdac: make SOF HDA codec driver probe deterministic 2020-09-21 23:57:24 +01:00
i2c
isa
mips
oss
parisc
pci ALSA: hdsp: convert tasklets to use new tasklet_setup() API 2020-09-02 13:25:23 +02:00
pcmcia
ppc
sh
soc ASoC: hdac: make SOF HDA codec driver probe deterministic 2020-09-21 23:57:24 +01:00
sparc
spi
synth
usb ALSA: ua101: convert tasklets to use new tasklet_setup() API 2020-09-02 13:27:07 +02:00
x86
xen
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c