Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT

We should have a limited trust in the BIOS and verify that the SSP
index reported in NHLT is valid for each platform.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220725195343.145603-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
e5169950 be0aa8d4

+7
+7
sound/soc/sof/intel/hda.c
··· 1527 1527 if (tplg_fixup && 1528 1528 mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && 1529 1529 mach->mach_params.i2s_link_mask) { 1530 + const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); 1530 1531 int ssp_num; 1531 1532 1532 1533 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && ··· 1536 1535 1537 1536 /* fls returns 1-based results, SSPs indices are 0-based */ 1538 1537 ssp_num = fls(mach->mach_params.i2s_link_mask) - 1; 1538 + 1539 + if (ssp_num >= chip->ssp_count) { 1540 + dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n", 1541 + ssp_num, chip->ssp_count); 1542 + return NULL; 1543 + } 1539 1544 1540 1545 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, 1541 1546 "%s%s%d",