linux-stable/sound/soc/intel
Hans de Goede 0cc65482f5
ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT boards harder
Since commit 13f58267cd ("ASoC: soc.h: don't create dummy Component
via COMP_DUMMY()") dummy codecs declared like this:

SND_SOC_DAILINK_DEF(dummy,
        DAILINK_COMP_ARRAY(COMP_DUMMY()));

expand to:

static struct snd_soc_dai_link_component dummy[] = {
};

Which means that dummy is a zero sized array and thus dais[i].codecs should
not be dereferenced *at all* since it points to the address of the next
variable stored in the data section as the "dummy" variable has an address
but no size, so even dereferencing dais[0] is already an out of bounds
array reference.

Which means that the if (dais[i].codecs->name) check added in
commit 7d99a70b65 ("ASoC: Intel: Boards: Fix NULL pointer deref
in BYT/CHT boards") relies on that the part of the next variable which
the name member maps to just happens to be NULL.

Which apparently so far it usually is, except when it isn't
and then it results in crashes like this one:

[   28.795659] BUG: unable to handle page fault for address: 0000000000030011
...
[   28.795780] Call Trace:
[   28.795787]  <TASK>
...
[   28.795862]  ? strcmp+0x18/0x40
[   28.795872]  0xffffffffc150c605
[   28.795887]  platform_probe+0x40/0xa0
...
[   28.795979]  ? __pfx_init_module+0x10/0x10 [snd_soc_sst_bytcr_wm5102]

Really fix things this time around by checking dais.num_codecs != 0.

Fixes: 7d99a70b65 ("ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT boards")
Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://patch.msgid.link/20240823074217.14653-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-23 11:02:52 +01:00
..
atom ASoC: intel: Use *-y instead of *-objs in Makefile 2024-05-08 11:39:20 +09:00
avs ASoC: Few constifications (mostly arguments) 2024-06-23 13:13:00 +01:00
boards ASoC: Intel: Boards: Fix NULL pointer deref in BYT/CHT boards harder 2024-08-23 11:02:52 +01:00
catpt ASoC: intel: Use *-y instead of *-objs in Makefile 2024-05-08 11:39:20 +09:00
common ASoC: Intel: use soc_intel_is_byt_cr() only when IOSF_MBI is reachable 2024-07-22 13:04:49 +01:00
keembay ASoC: intel: Use *-y instead of *-objs in Makefile 2024-05-08 11:39:20 +09:00
skylake ASoC: Intel: Skylake: Constify struct snd_soc_tplg_ops 2024-05-27 01:31:18 +01:00
Kconfig ASoC: Intel: avs: Switch to ACPI NHLT 2024-04-21 23:35:13 +09:00
Makefile ASoC: Intel: Introduce AVS driver 2022-03-11 16:23:54 +00:00