Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46712646 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Report errors when invalid values are passed to snd_hda_amp_*()



The values should be in 8 bits.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 55440e4e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1461,6 +1461,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
	info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
	if (!info)
		return 0;
	if (snd_BUG_ON(mask & ~0xff))
		mask &= 0xff;
	val &= mask;
	val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
	if (info->vol[ch] == val)
@@ -1486,6 +1488,9 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
			     int direction, int idx, int mask, int val)
{
	int ch, ret = 0;

	if (snd_BUG_ON(mask & ~0xff))
		mask &= 0xff;
	for (ch = 0; ch < 2; ch++)
		ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
						idx, mask, val);