Skip to content

Commit 3b44ec8

Browse files
committed
ALSA: hda: Fix Oops by 9.1 surround channel names
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 <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent cc638db commit 3b44ec8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sound/pci/hda/hda_generic.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,8 @@ static bool path_has_mixer(struct hda_codec *codec, int path_idx, int ctl_type)
11551155
return path && path->ctls[ctl_type];
11561156
}
11571157

1158-
static const char * const channel_name[4] = {
1159-
"Front", "Surround", "CLFE", "Side"
1158+
static const char * const channel_name[] = {
1159+
"Front", "Surround", "CLFE", "Side", "Back",
11601160
};
11611161

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

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

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

1237+
fixed_name:
12371238
if (ch >= ARRAY_SIZE(channel_name)) {
12381239
snd_BUG();
12391240
return "PCM";

0 commit comments

Comments
 (0)