Skip to content

Commit 255cc58

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: Intel: sof_sdw: Add space for a terminator into DAIs array
The code uses the initialised member of the asoc_sdw_dailink struct to determine if a member of the array is in use. However in the case the array is completely full this will lead to an access 1 past the end of the array, expand the array by one entry to include a space for a terminator. Fixes: 27fd36a ("ASoC: Intel: sof-sdw: Add new code for parsing the snd_soc_acpi structs") Reviewed-by: Bard Liao <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Signed-off-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent bb76e82 commit 255cc58

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,12 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
10671067
return ret;
10681068
}
10691069

1070-
/* One per DAI link, worst case is a DAI link for every endpoint */
1071-
sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL);
1070+
/*
1071+
* One per DAI link, worst case is a DAI link for every endpoint, also
1072+
* add one additional to act as a terminator such that code can iterate
1073+
* until it hits an uninitialised DAI.
1074+
*/
1075+
sof_dais = kcalloc(num_ends + 1, sizeof(*sof_dais), GFP_KERNEL);
10721076
if (!sof_dais)
10731077
return -ENOMEM;
10741078

0 commit comments

Comments
 (0)