Skip to content

Commit c7dab67

Browse files
brentlubroonie
authored andcommitted
ASoC: Intel: sof_rt5682: fix out-of-bounds array access
Starting from ADL platform we have four HDMI PCM devices which exceeds the size of sof_hdmi array. Since each sof_hdmi_pcm structure represents one HDMI PCM device, we remove the sof_hdmi array and add a new member hdmi_jack to the sof_hdmi_pcm structure to fix the out-of-bounds problem. Signed-off-by: Brent Lu <brent.lu@intel.com> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20220701141517.264070-1-brent.lu@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent df5b4ac commit c7dab67

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

sound/soc/intel/boards/sof_rt5682.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
6969

7070
static int is_legacy_cpu;
7171

72-
static struct snd_soc_jack sof_hdmi[3];
73-
7472
struct sof_hdmi_pcm {
7573
struct list_head head;
7674
struct snd_soc_dai *codec_dai;
75+
struct snd_soc_jack hdmi_jack;
7776
int device;
7877
};
7978

@@ -434,7 +433,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
434433
char jack_name[NAME_SIZE];
435434
struct sof_hdmi_pcm *pcm;
436435
int err;
437-
int i = 0;
438436

439437
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
440438
if (is_legacy_cpu || !ctx->idisp_codec)
@@ -455,17 +453,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
455453
snprintf(jack_name, sizeof(jack_name),
456454
"HDMI/DP, pcm=%d Jack", pcm->device);
457455
err = snd_soc_card_jack_new(card, jack_name,
458-
SND_JACK_AVOUT, &sof_hdmi[i]);
456+
SND_JACK_AVOUT, &pcm->hdmi_jack);
459457

460458
if (err)
461459
return err;
462460

463461
err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
464-
&sof_hdmi[i]);
462+
&pcm->hdmi_jack);
465463
if (err < 0)
466464
return err;
467-
468-
i++;
469465
}
470466

471467
if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {

0 commit comments

Comments
 (0)