ALSA: hda - Report errors when invalid values are passed to snd_hda_amp_*()
authorTakashi Iwai <tiwai@suse.de>
Mon, 29 Mar 2010 07:19:38 +0000 (09:19 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 29 Mar 2010 07:20:39 +0000 (09:20 +0200)
The values should be in 8 bits.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c

index d72bcff8d271ccf7b2e7b43c8c72e365d5b7d8d6..d1424e7b9f3dfffd3b914ed35d5d928c981486ce 100644 (file)
@@ -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);