Skip to content

Commit 0ad3f0b

Browse files
committed
ALSA: hda: Fix potential access overflow in beep helper
The beep control helper function blindly stores the values in two stereo channels no matter whether the actual control is mono or stereo. This is practically harmless, but it annoys the recently introduced sanity check, resulting in an error when the checker is enabled. This patch corrects the behavior to store only on the defined array member. Fixes: 0401e85 ("ALSA: hda - Move beep helper functions to hda_beep.c") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207139 Reviewed-by: Jaroslav Kysela <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 24164f4 commit 0ad3f0b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sound/pci/hda/hda_beep.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,12 @@ int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
290290
{
291291
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
292292
struct hda_beep *beep = codec->beep;
293+
int chs = get_amp_channels(kcontrol);
294+
293295
if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) {
294-
ucontrol->value.integer.value[0] =
296+
if (chs & 1)
297+
ucontrol->value.integer.value[0] = beep->enabled;
298+
if (chs & 2)
295299
ucontrol->value.integer.value[1] = beep->enabled;
296300
return 0;
297301
}

0 commit comments

Comments
 (0)