Skip to content

Commit 7f881ed

Browse files
ujfalusimehmetb0
authored andcommitted
ASoC: SOF: ipc4-topology: Harden loops for looking up ALH copiers
BugLink: https://bugs.launchpad.net/bugs/2106494 [ Upstream commit 6fd60136d256b3b948333ebdb3835f41a95ab7ef ] 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]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 02ff177 commit 7f881ed

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)