[alsa-devel] [PATCH 1/2] ALSA: hda - Fix possible zero-division

Takashi Iwai tiwai at suse.de
Mon Nov 4 17:08:29 CET 2013


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 at suse.de>
---
 sound/pci/hda/hda_codec.c | 9 +++++++--
 1 file 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)
 		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;
 }
 
-- 
1.8.4.2



More information about the Alsa-devel mailing list