linux-stable/sound/hda
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
..
ext ASoC: hdac: make SOF HDA codec driver probe deterministic 2020-09-21 23:57:24 +01:00
array.c
hda_bus_type.c
hdac_bus.c ALSA: hda: avoid reset of sdo_limit 2020-08-19 17:37:06 +02:00
hdac_component.c
hdac_controller.c ALSA: hda: avoid reset of sdo_limit 2020-08-19 17:37:06 +02:00
hdac_device.c ALSA: hda: Use dev_to_hdac_dev macro 2020-05-05 08:58:35 +02:00
hdac_i915.c
hdac_regmap.c
hdac_stream.c ALSA: hda: Add dma stop delay variable 2020-08-05 12:27:47 +02:00
hdac_sysfs.c
hdmi_chmap.c
intel-dsp-config.c ASoC: Fixes for v5.8 2020-06-22 13:49:14 +02:00
intel-nhlt.c ASoC: Updates for v5.8 2020-06-01 20:26:07 +02:00
Kconfig ALSA: hda: Allow setting preallocation again for x86 2020-04-13 22:22:28 +02:00
local.h ALSA: hda: Unexport some local helper functions 2020-05-16 08:29:49 +02:00
Makefile
trace.c
trace.h