public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.13 01/16] ASoC: SOF: Intel: hda-dai: Ensure DAI widget is valid during params
@ 2025-01-26 15:07 Sasha Levin
  2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 02/16] bpf: Improve verifier log for resource leak on exit Sasha Levin
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: Sasha Levin @ 2025-01-26 15:07 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Bard Liao, Ranjani Sridharan, Péter Ujfalusi, Liam Girdwood,
	Mark Brown, Sasha Levin, lgirdwood, daniel.baluta, perex, tiwai,
	pierre-louis.bossart, peterz, kai.vehmanen, brent.lu,
	sound-open-firmware, linux-sound

From: Bard Liao <yung-chuan.liao@linux.intel.com>

[ Upstream commit 569922b82ca660f8b24e705f6cf674e6b1f99cc7 ]

Each cpu DAI should associate with a widget. However, the topology might
not create the right number of DAI widgets for aggregated amps. And it
will cause NULL pointer deference.
Check that the DAI widget associated with the CPU DAI is valid to prevent
NULL pointer deference due to missing DAI widgets in topologies with
aggregated amps.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Link: https://patch.msgid.link/20241203104853.56956-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/sof/intel/hda-dai.c | 12 ++++++++++++
 sound/soc/sof/intel/hda.c     |  5 +++++
 2 files changed, 17 insertions(+)

diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index 0db2a3e554fb2..da12aabc1bb85 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -503,6 +503,12 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream,
 	int ret;
 	int i;
 
+	if (!w) {
+		dev_err(cpu_dai->dev, "%s widget not found, check amp link num in the topology\n",
+			cpu_dai->name);
+		return -EINVAL;
+	}
+
 	ops = hda_dai_get_ops(substream, cpu_dai);
 	if (!ops) {
 		dev_err(cpu_dai->dev, "DAI widget ops not set\n");
@@ -582,6 +588,12 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream,
 	 */
 	for_each_rtd_cpu_dais(rtd, i, dai) {
 		w = snd_soc_dai_get_widget(dai, substream->stream);
+		if (!w) {
+			dev_err(cpu_dai->dev,
+				"%s widget not found, check amp link num in the topology\n",
+				dai->name);
+			return -EINVAL;
+		}
 		ipc4_copier = widget_to_copier(w);
 		memcpy(&ipc4_copier->dma_config_tlv[cpu_dai_id], dma_config_tlv,
 		       sizeof(*dma_config_tlv));
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index f991785f727e9..be689f6e10c81 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -63,6 +63,11 @@ static int sdw_params_stream(struct device *dev,
 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(d, params_data->substream->stream);
 	struct snd_sof_dai_config_data data = { 0 };
 
+	if (!w) {
+		dev_err(dev, "%s widget not found, check amp link num in the topology\n",
+			d->name);
+		return -EINVAL;
+	}
 	data.dai_index = (params_data->link_id << 8) | d->id;
 	data.dai_data = params_data->alh_stream_id;
 	data.dai_node_id = data.dai_data;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-02-05 21:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 15:07 [PATCH AUTOSEL 6.13 01/16] ASoC: SOF: Intel: hda-dai: Ensure DAI widget is valid during params Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 02/16] bpf: Improve verifier log for resource leak on exit Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 03/16] x86/kexec: Allocate PGD for x86_64 transition page tables separately Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 04/16] ASoC: Intel: sof_sdw: Correct quirk for Lenovo Yoga Slim 7 Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 05/16] iommu/arm-smmu-qcom: add sdm670 adreno iommu compatible Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 06/16] tool api fs: Correctly encode errno for read/write open failures Sasha Levin
2025-01-26 18:27   ` Ian Rogers
2025-01-26 20:41     ` Namhyung Kim
2025-02-05 21:53       ` Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 07/16] iommu/arm-smmu-v3: Clean up more on probe failure Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 08/16] platform/x86: int3472: Check for adev == NULL Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 09/16] platform/x86: acer-wmi: Add support for Acer PH14-51 Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 10/16] ASoC: soc-pcm: don't use soc_pcm_ret() on .prepare callback Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 11/16] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 12/16] platform/x86: acer-wmi: Add support for Acer Predator PH16-72 Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 13/16] ASoC: amd: Add ACPI dependency to fix build error Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 14/16] Input: allocate keycode for phone linking Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 15/16] platform/x86: acer-wmi: add support for Acer Nitro AN515-58 Sasha Levin
2025-01-26 15:07 ` [PATCH AUTOSEL 6.13 16/16] platform/x86: acer-wmi: Ignore AC events Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox