Skip to content

Commit

Permalink
ASoC: Intel: sof_rt5682: fix out-of-bounds array access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brent Lu authored and Mark Brown committed Jul 7, 2022
1 parent df5b4ac commit c7dab67
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions sound/soc/intel/boards/sof_rt5682.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |

static int is_legacy_cpu;

static struct snd_soc_jack sof_hdmi[3];

struct sof_hdmi_pcm {
struct list_head head;
struct snd_soc_dai *codec_dai;
struct snd_soc_jack hdmi_jack;
int device;
};

Expand Down Expand Up @@ -434,7 +433,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
char jack_name[NAME_SIZE];
struct sof_hdmi_pcm *pcm;
int err;
int i = 0;

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

if (err)
return err;

err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
&sof_hdmi[i]);
&pcm->hdmi_jack);
if (err < 0)
return err;

i++;
}

if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
Expand Down

0 comments on commit c7dab67

Please sign in to comment.