]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Fix possible zero-division
authorTakashi Iwai <tiwai@suse.de>
Mon, 4 Nov 2013 14:44:09 +0000 (15:44 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 5 Nov 2013 06:47:52 +0000 (07:47 +0100)
Check the TLV db scale result before actually dividing in vmaster
slave init code.  Also mask TLV_DB_SCALE_MUTE bit so that the right
value is obtained even if this bit is set by the codec driver.

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

index de1a7670ba0dfe5f165277170a19aae9004a5c4b..33c01d551aa482fffc1c07d18792b6453a330e90 100644 (file)
@@ -2676,8 +2676,13 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl)
                set_fs(fs);
        } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
                tlv = kctl->tlv.p;
-       if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE)
-               val = -tlv[2] / tlv[3];
+       if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) {
+               int step = tlv[3];
+               step &= ~TLV_DB_SCALE_MUTE;
+               if (!step)
+                       return -1;
+               val = -tlv[2] / step;
+       }
        return val;
 }