ALSA: hdspm: Fix wrong boolean ctl value accesses
PATCH 1/2 ALSA: hdspm: Fix wrong boolean ctl value accesses
snd-hdspm driver accesses enum item values (int) instead of boolean values (long) wrongly for some ctl elements. This patch fixes them.
Cc <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/pci/rme9652/hdspm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/pci/rme9652/hdspm.c +4 -4
@@ -2261,7 +2261,7 @@ static int snd_hdspm_put_system_sample_rate(struct snd_kcontrol *kcontrol, {struct hdspm *hdspm =snd_kcontrol_chip (kcontrol); -hdspm_set_dds_value (hdspm, ucontrol->value.enumerated.item[0 ]); +hdspm_set_dds_value (hdspm, ucontrol->value.integer.value[0 ]);return 0 ; }
@@ -4449,7 +4449,7 @@ static int snd_hdspm_get_tco_word_term(struct snd_kcontrol *kcontrol, {struct hdspm *hdspm =snd_kcontrol_chip (kcontrol); - ucontrol->value.enumerated.item[0 ] = hdspm->tco->term; + ucontrol->value.integer.value[0 ] = hdspm->tco->term;return 0 ; }
@@ -4460,8 +4460,8 @@ static int snd_hdspm_put_tco_word_term(struct snd_kcontrol *kcontrol, {struct hdspm *hdspm =snd_kcontrol_chip (kcontrol); -if (hdspm->tco->term != ucontrol->value.enumerated.item[0 ]) { - hdspm->tco->term = ucontrol->value.enumerated.item[0 ]; +if (hdspm->tco->term != ucontrol->value.integer.value[0 ]) { + hdspm->tco->term = ucontrol->value.integer.value[0 ];hdspm_tco_write (hdspm);
Signature · 1 line
2.7.2
PATCH 2/2 ALSA: hdspm: Fix zero-division
HDSPM driver contains a code issuing zero-division potentially in system sample rate ctl code. This patch fixes it by not processing a zero or invalid rate value as a divisor, as well as excluding the invalid value to be passed via the given ctl element.
Cc <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/pci/rme9652/hdspm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/pci/rme9652/hdspm.c +8 -0
@@ -1601,6 +1601,9 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) {u64 n; +if (snd_BUG_ON (rate <=0 )) +return ; +if (rate >=112000 ) rate /=4 ;else if (rate >=56000 )
@@ -2215,6 +2218,8 @@ static int hdspm_get_system_sample_rate(struct hdspm *hdspm) }else {/* slave mode, return external sample rate */ rate =hdspm_external_sample_rate (hdspm); +if (!rate) + rate = hdspm->system_sample_rate; } }
@@ -2260,7 +2265,10 @@ static int snd_hdspm_put_system_sample_rate(struct snd_kcontrol *kcontrol, ucontrol) {struct hdspm *hdspm =snd_kcontrol_chip (kcontrol); +int rate = ucontrol->value.integer.value[0 ]; +if (rate <27000 || rate >207000 ) +return -EINVAL ;hdspm_set_dds_value (hdspm, ucontrol->value.integer.value[0 ]);return 0 ; }
Signature · 1 line
2.7.2