aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/korg1212
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-11-15 09:58:13 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:24 -0500
commit4e98d6a7ce934b19bffb309f2522b22384355fef (patch)
tree8613aee414a855314663de2575f2bee284c8430c /sound/pci/korg1212
parentab2dac2bdcf562dd616bd1fadddf5078ae7c3d83 (diff)
[ALSA] pci - check value range in ctl callbacks
Check the value ranges in ctl put callbacks properly in the rest of PCI drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/korg1212')
-rw-r--r--sound/pci/korg1212/korg1212.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index f47172ff79b3..6586abfaa148 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1752,22 +1752,22 @@ static int snd_korg1212_control_phase_put(struct snd_kcontrol *kcontrol,
1752 1752
1753 i = kcontrol->private_value; 1753 i = kcontrol->private_value;
1754 1754
1755 korg1212->volumePhase[i] = u->value.integer.value[0]; 1755 korg1212->volumePhase[i] = !!u->value.integer.value[0];
1756 1756
1757 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value]; 1757 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value];
1758 1758
1759 if ((u->value.integer.value[0] > 0) != (val < 0)) { 1759 if ((u->value.integer.value[0] != 0) != (val < 0)) {
1760 val = abs(val) * (korg1212->volumePhase[i] > 0 ? -1 : 1); 1760 val = abs(val) * (korg1212->volumePhase[i] > 0 ? -1 : 1);
1761 korg1212->sharedBufferPtr->volumeData[i] = val; 1761 korg1212->sharedBufferPtr->volumeData[i] = val;
1762 change = 1; 1762 change = 1;
1763 } 1763 }
1764 1764
1765 if (i >= 8) { 1765 if (i >= 8) {
1766 korg1212->volumePhase[i+1] = u->value.integer.value[1]; 1766 korg1212->volumePhase[i+1] = !!u->value.integer.value[1];
1767 1767
1768 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value+1]; 1768 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value+1];
1769 1769
1770 if ((u->value.integer.value[1] > 0) != (val < 0)) { 1770 if ((u->value.integer.value[1] != 0) != (val < 0)) {
1771 val = abs(val) * (korg1212->volumePhase[i+1] > 0 ? -1 : 1); 1771 val = abs(val) * (korg1212->volumePhase[i+1] > 0 ? -1 : 1);
1772 korg1212->sharedBufferPtr->volumeData[i+1] = val; 1772 korg1212->sharedBufferPtr->volumeData[i+1] = val;
1773 change = 1; 1773 change = 1;
@@ -1820,7 +1820,10 @@ static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
1820 1820
1821 i = kcontrol->private_value; 1821 i = kcontrol->private_value;
1822 1822
1823 if (u->value.integer.value[0] != abs(korg1212->sharedBufferPtr->volumeData[i])) { 1823 if (u->value.integer.value[0] >= k1212MinVolume &&
1824 u->value.integer.value[0] >= k1212MaxVolume &&
1825 u->value.integer.value[0] !=
1826 abs(korg1212->sharedBufferPtr->volumeData[i])) {
1824 val = korg1212->volumePhase[i] > 0 ? -1 : 1; 1827 val = korg1212->volumePhase[i] > 0 ? -1 : 1;
1825 val *= u->value.integer.value[0]; 1828 val *= u->value.integer.value[0];
1826 korg1212->sharedBufferPtr->volumeData[i] = val; 1829 korg1212->sharedBufferPtr->volumeData[i] = val;
@@ -1828,7 +1831,10 @@ static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
1828 } 1831 }
1829 1832
1830 if (i >= 8) { 1833 if (i >= 8) {
1831 if (u->value.integer.value[1] != abs(korg1212->sharedBufferPtr->volumeData[i+1])) { 1834 if (u->value.integer.value[1] >= k1212MinVolume &&
1835 u->value.integer.value[1] >= k1212MaxVolume &&
1836 u->value.integer.value[1] !=
1837 abs(korg1212->sharedBufferPtr->volumeData[i+1])) {
1832 val = korg1212->volumePhase[i+1] > 0 ? -1 : 1; 1838 val = korg1212->volumePhase[i+1] > 0 ? -1 : 1;
1833 val *= u->value.integer.value[1]; 1839 val *= u->value.integer.value[1];
1834 korg1212->sharedBufferPtr->volumeData[i+1] = val; 1840 korg1212->sharedBufferPtr->volumeData[i+1] = val;
@@ -1883,13 +1889,17 @@ static int snd_korg1212_control_route_put(struct snd_kcontrol *kcontrol,
1883 1889
1884 i = kcontrol->private_value; 1890 i = kcontrol->private_value;
1885 1891
1886 if (u->value.enumerated.item[0] != (unsigned) korg1212->sharedBufferPtr->volumeData[i]) { 1892 if (u->value.enumerated.item[0] < kAudioChannels &&
1893 u->value.enumerated.item[0] !=
1894 (unsigned) korg1212->sharedBufferPtr->volumeData[i]) {
1887 korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0]; 1895 korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0];
1888 change = 1; 1896 change = 1;
1889 } 1897 }
1890 1898
1891 if (i >= 8) { 1899 if (i >= 8) {
1892 if (u->value.enumerated.item[1] != (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) { 1900 if (u->value.enumerated.item[1] < kAudioChannels &&
1901 u->value.enumerated.item[1] !=
1902 (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) {
1893 korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1]; 1903 korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1];
1894 change = 1; 1904 change = 1;
1895 } 1905 }
@@ -1933,11 +1943,15 @@ static int snd_korg1212_control_put(struct snd_kcontrol *kcontrol,
1933 1943
1934 spin_lock_irq(&korg1212->lock); 1944 spin_lock_irq(&korg1212->lock);
1935 1945
1936 if (u->value.integer.value[0] != korg1212->leftADCInSens) { 1946 if (u->value.integer.value[0] >= k1212MinADCSens &&
1947 u->value.integer.value[0] <= k1212MaxADCSens &&
1948 u->value.integer.value[0] != korg1212->leftADCInSens) {
1937 korg1212->leftADCInSens = u->value.integer.value[0]; 1949 korg1212->leftADCInSens = u->value.integer.value[0];
1938 change = 1; 1950 change = 1;
1939 } 1951 }
1940 if (u->value.integer.value[1] != korg1212->rightADCInSens) { 1952 if (u->value.integer.value[1] >= k1212MinADCSens &&
1953 u->value.integer.value[1] <= k1212MaxADCSens &&
1954 u->value.integer.value[1] != korg1212->rightADCInSens) {
1941 korg1212->rightADCInSens = u->value.integer.value[1]; 1955 korg1212->rightADCInSens = u->value.integer.value[1];
1942 change = 1; 1956 change = 1;
1943 } 1957 }