Skip to content

Commit 6fd6013

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-topology: Harden loops for looking up ALH copiers
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 <[email protected]> Link: thesofproject/sof#9652 Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Liam Girdwood <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Bard Liao <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1d44a30 commit 6fd6013

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
@@ -765,10 +765,16 @@ static int sof_ipc4_widget_setup_comp_dai(struct snd_sof_widget *swidget)
765765
}
766766

767767
list_for_each_entry(w, &sdev->widget_list, list) {
768-
if (w->widget->sname &&
768+
struct snd_sof_dai *alh_dai;
769+
770+
if (!WIDGET_IS_DAI(w->id) || !w->widget->sname ||
769771
strcmp(w->widget->sname, swidget->widget->sname))
770772
continue;
771773

774+
alh_dai = w->private;
775+
if (alh_dai->type != SOF_DAI_INTEL_ALH)
776+
continue;
777+
772778
blob->alh_cfg.device_count++;
773779
}
774780

@@ -2061,11 +2067,13 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
20612067
list_for_each_entry(w, &sdev->widget_list, list) {
20622068
u32 node_type;
20632069

2064-
if (w->widget->sname &&
2070+
if (!WIDGET_IS_DAI(w->id) || !w->widget->sname ||
20652071
strcmp(w->widget->sname, swidget->widget->sname))
20662072
continue;
20672073

20682074
dai = w->private;
2075+
if (dai->type != SOF_DAI_INTEL_ALH)
2076+
continue;
20692077
alh_copier = (struct sof_ipc4_copier *)dai->private;
20702078
alh_data = &alh_copier->data;
20712079
node_type = SOF_IPC4_GET_NODE_TYPE(alh_data->gtw_cfg.node_id);

0 commit comments

Comments
 (0)