Skip to content

Commit 5a72ff8

Browse files
ujfalusibardliao
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: 0e357b5 ("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>
1 parent a1f6c35 commit 5a72ff8

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

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

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

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

2065-
if (w->widget->sname &&
2071+
if (!WIDGET_IS_DAI(w->id) || !w->widget->sname ||
20662072
strcmp(w->widget->sname, swidget->widget->sname))
20672073
continue;
20682074

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

0 commit comments

Comments
 (0)