ASoC: Merge dropped fixes from v5.18
[sfrench/cifs-2.6.git] / sound / soc / soc-ops.c
index bd88de056358355d5ac70e86778fa2df547de84b..1970bda074d8ac9fa44049d5c83fa98f8940eb00 100644 (file)
@@ -452,7 +452,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
        val = ucontrol->value.integer.value[0];
        if (mc->platform_max && val > mc->platform_max)
                return -EINVAL;
-       if (val > max - min)
+       if (val > max)
                return -EINVAL;
        val_mask = mask << shift;
        val = (val + min) & mask;
@@ -468,6 +468,12 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 
                val_mask = mask << rshift;
                val2 = (ucontrol->value.integer.value[1] + min) & mask;
+
+               if (mc->platform_max && val2 > mc->platform_max)
+                       return -EINVAL;
+               if (val2 > max)
+                       return -EINVAL;
+
                val2 = val2 << rshift;
 
                err = snd_soc_component_update_bits(component, reg2, val_mask,