aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Robert <baptistex.robert@intel.com>2013-08-07 11:32:45 +0200
committerDavid Wagner <david.wagner@intel.com>2014-05-06 19:36:06 +0200
commit6cd7d5f9870ef548bcb5a941061eeed9ad6b0d16 (patch)
treebc238785004f183d92572432af40edfb8dda71e3
parent867920ca46cc8ddc726bc0d406c454c17b7b9262 (diff)
Mixer: Check validity of input value
When the user wants to set a mixer with a value greater than the maximum or smaller than the minimum, the mixer is set at an undefined value. This patch set purpose is to return a error if the input value is out of range. Signed-off-by: Baptiste Robert <baptistex.robert@intel.com> Signed-off-by: David Wagner <david.wagner@intel.com> Author-Tracking-BZ: 129089
-rw-r--r--mixer.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mixer.c b/mixer.c
index 8e99fad..b6c854f 100644
--- a/mixer.c
+++ b/mixer.c
@@ -392,6 +392,11 @@ int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value)
break;
case SNDRV_CTL_ELEM_TYPE_INTEGER:
+ if ((value < mixer_ctl_get_range_min(ctl)) ||
+ (value > mixer_ctl_get_range_max(ctl))) {
+ return -EINVAL;
+ }
+
ev.value.integer.value[id] = value;
break;