Skip to content

Commit

Permalink
ALSA: hda: Fix Oops by 9.1 surround channel names
Browse files Browse the repository at this point in the history
commit 3b44ec8 upstream.

get_line_out_pfx() may trigger an Oops by overflowing the static array
with more than 8 channels.  This was reported for MacBookPro 12,1 with
Cirrus codec.

As a workaround, extend for the 9.1 channels and also fix the
potential Oops by unifying the code paths accessing the same array
with the proper size check.

Reported-by: Olliver Schinagl <oliver@schinagl.nl>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/64d95eb0-dbdb-cff8-a8b1-988dc22b24cd@schinagl.nl
Link: https://lore.kernel.org/r/20230516184412.24078-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
tiwai authored and gregkh committed May 24, 2023
1 parent c7cf2ce commit fcf6374
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sound/pci/hda/hda_generic.c
Expand Up @@ -1155,8 +1155,8 @@ static bool path_has_mixer(struct hda_codec *codec, int path_idx, int ctl_type)
return path && path->ctls[ctl_type];
}

static const char * const channel_name[4] = {
"Front", "Surround", "CLFE", "Side"
static const char * const channel_name[] = {
"Front", "Surround", "CLFE", "Side", "Back",
};

/* give some appropriate ctl name prefix for the given line out channel */
Expand All @@ -1182,7 +1182,7 @@ static const char *get_line_out_pfx(struct hda_codec *codec, int ch,

/* multi-io channels */
if (ch >= cfg->line_outs)
return channel_name[ch];
goto fixed_name;

switch (cfg->line_out_type) {
case AUTO_PIN_SPEAKER_OUT:
Expand Down Expand Up @@ -1234,6 +1234,7 @@ static const char *get_line_out_pfx(struct hda_codec *codec, int ch,
if (cfg->line_outs == 1 && !spec->multi_ios)
return "Line Out";

fixed_name:
if (ch >= ARRAY_SIZE(channel_name)) {
snd_BUG();
return "PCM";
Expand Down

0 comments on commit fcf6374

Please sign in to comment.