Skip to content

Commit 87c8768

Browse files
ujfalusigregkh
authored andcommitted
ASoC: SOF: ipc4-topology: Harden loops for looking up ALH copiers
[ Upstream commit 6fd6013 ] Other, non DAI copier widgets could have the same stream name (sname) as the ALH copier and in that case the copier->data is NULL, no alh_data is attached, which could lead to NULL pointer dereference. We could check for this NULL pointer in sof_ipc4_prepare_copier_module() and avoid the crash, but a similar loop in sof_ipc4_widget_setup_comp_dai() will miscalculate the ALH device count, causing broken audio. The correct fix is to harden the matching logic by making sure that the 1. widget is a DAI widget - so dai = w->private is valid 2. the dai (and thus the copier) is ALH copier Fixes: a150345 ("ASoC: SOF: ipc4-topology: add SoundWire/ALH aggregation support") Reported-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> Link: thesofproject/sof#9652 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://patch.msgid.link/20250206084642.14988-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8de1ea6 commit 87c8768

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,16 @@ static int sof_ipc4_widget_setup_comp_dai(struct snd_sof_widget *swidget)
671671
}
672672

673673
list_for_each_entry(w, &sdev->widget_list, list) {
674-
if (w->widget->sname &&
674+
struct snd_sof_dai *alh_dai;
675+
676+
if (!WIDGET_IS_DAI(w->id) || !w->widget->sname ||
675677
strcmp(w->widget->sname, swidget->widget->sname))
676678
continue;
677679

680+
alh_dai = w->private;
681+
if (alh_dai->type != SOF_DAI_INTEL_ALH)
682+
continue;
683+
678684
blob->alh_cfg.device_count++;
679685
}
680686

@@ -1973,11 +1979,13 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19731979
list_for_each_entry(w, &sdev->widget_list, list) {
19741980
u32 node_type;
19751981

1976-
if (w->widget->sname &&
1982+
if (!WIDGET_IS_DAI(w->id) || !w->widget->sname ||
19771983
strcmp(w->widget->sname, swidget->widget->sname))
19781984
continue;
19791985

19801986
dai = w->private;
1987+
if (dai->type != SOF_DAI_INTEL_ALH)
1988+
continue;
19811989
alh_copier = (struct sof_ipc4_copier *)dai->private;
19821990
alh_data = &alh_copier->data;
19831991
node_type = SOF_IPC4_GET_NODE_TYPE(alh_data->gtw_cfg.node_id);

0 commit comments

Comments
 (0)