Skip to content

Commit 3c45e74

Browse files
charleskeepaxSasha Levin
authored andcommitted
ASoC: Intel: sof_sdw: Add space for a terminator into DAIs array
[ Upstream commit 255cc58 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 80d9663 commit 3c45e74

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
@@ -1003,8 +1003,12 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
10031003
return ret;
10041004
}
10051005

1006-
/* One per DAI link, worst case is a DAI link for every endpoint */
1007-
sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL);
1006+
/*
1007+
* One per DAI link, worst case is a DAI link for every endpoint, also
1008+
* add one additional to act as a terminator such that code can iterate
1009+
* until it hits an uninitialised DAI.
1010+
*/
1011+
sof_dais = kcalloc(num_ends + 1, sizeof(*sof_dais), GFP_KERNEL);
10081012
if (!sof_dais)
10091013
return -ENOMEM;
10101014

0 commit comments

Comments
 (0)