Skip to content

Commit

Permalink
ALSA: hda - Always check array bounds in alc_get_line_out_pfx
Browse files Browse the repository at this point in the history
Even when CONFIG_SND_DEBUG is not enabled, we don't want to
return an arbitrary memory location when the channel count is
larger than we expected.

Cc: stable@kernel.org
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
David Henningsson authored and Takashi Iwai committed Oct 17, 2012
1 parent 1f04661 commit 71aa5eb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -2598,8 +2598,10 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
return "PCM";
break;
}
if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
if (ch >= ARRAY_SIZE(channel_name)) {
snd_BUG();
return "PCM";
}

return channel_name[ch];
}
Expand Down

0 comments on commit 71aa5eb

Please sign in to comment.