Browse Source

asoc: wsa884x: Out of bound check for wsa dev mode.

Out of bound check for wsa dev mode.

Change-Id: I7a244b8f7a55e4ced06991ce8e945d737eac6f77
Signed-off-by: Ganapathiraju Sarath Varma <[email protected]>
Ganapathiraju Sarath Varma 2 years ago
parent
commit
7968abf8db
1 changed files with 6 additions and 1 deletions
  1. 6 1
      asoc/codecs/wsa884x/wsa884x.c

+ 6 - 1
asoc/codecs/wsa884x/wsa884x.c

@@ -798,7 +798,12 @@ static int wsa_dev_mode_put(struct snd_kcontrol *kcontrol,
 	int dev_mode;
 	int wsa_dev_index;
 
-	dev_mode = ucontrol->value.integer.value[0];
+	if ((ucontrol->value.integer.value[0] >= SPEAKER) &&
+			(ucontrol->value.integer.value[0] < MAX_DEV_MODE))
+		dev_mode = ucontrol->value.integer.value[0];
+	else
+		return -EINVAL;
+
 	dev_dbg(component->dev, "%s: Dev Mode current: %d, new: %d\n",
 		__func__, wsa884x->dev_mode, dev_mode);