[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220814161943.2394452-24-sashal@kernel.org>
Date: Sun, 14 Aug 2022 12:19:17 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>,
Bard Liao <yung-chuan.liao@...ux.intel.com>,
Mark Brown <broonie@...nel.org>,
Sasha Levin <sashal@...nel.org>, lgirdwood@...il.com,
peter.ujfalusi@...ux.intel.com, daniel.baluta@....com,
perex@...ex.cz, tiwai@...e.com, kai.vehmanen@...ux.intel.com,
guennadi.liakhovetski@...ux.intel.com,
sound-open-firmware@...a-project.org, alsa-devel@...a-project.org
Subject: [PATCH AUTOSEL 5.19 24/48] ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
[ Upstream commit e51699505042fb365df3a0ce68b850ccd9ad0108 ]
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@...ux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@...ux.intel.com>
Link: https://lore.kernel.org/r/20220725195343.145603-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
sound/soc/sof/intel/hda.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index bc07df1fc39f..328be26e2dbb 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -1395,6 +1395,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER &&
mach->mach_params.i2s_link_mask) {
+ const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
int ssp_num;
if (hweight_long(mach->mach_params.i2s_link_mask) > 1 &&
@@ -1404,6 +1405,12 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev)
/* fls returns 1-based results, SSPs indices are 0-based */
ssp_num = fls(mach->mach_params.i2s_link_mask) - 1;
+ if (ssp_num >= chip->ssp_count) {
+ dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n",
+ ssp_num, chip->ssp_count);
+ return NULL;
+ }
+
tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
"%s%s%d",
sof_pdata->tplg_filename,
--
2.35.1
Powered by blists - more mailing lists