aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-11-04 09:44:09 -0500
committerTakashi Iwai <tiwai@suse.de>2013-11-05 01:47:52 -0500
commita4e7a121685a137eeeb01f05d5ed570c1b45017a (patch)
treeaedaf3304fa5a8c16bd48c712d373e4dcd5cde8a /sound/pci/hda/hda_codec.c
parent504333df8ba5fc310260285a22ab5d7cf3208795 (diff)
ALSA: hda - Fix possible zero-division
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>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index de1a7670ba0d..33c01d551aa4 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2676,8 +2676,13 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl)
2676 set_fs(fs); 2676 set_fs(fs);
2677 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) 2677 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
2678 tlv = kctl->tlv.p; 2678 tlv = kctl->tlv.p;
2679 if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) 2679 if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) {
2680 val = -tlv[2] / tlv[3]; 2680 int step = tlv[3];
2681 step &= ~TLV_DB_SCALE_MUTE;
2682 if (!step)
2683 return -1;
2684 val = -tlv[2] / step;
2685 }
2681 return val; 2686 return val;
2682} 2687}
2683 2688