asoc: codecs: Fix Bolero and WSA out-of-range variables

Found potential issues relating to uninitialized or out-of-bounds variables
present in codec drivers. Place checks to ensure proper ranges are used.

Change-Id: Ib68cba2413788a57237f1f18fc5ce5fb5c6bfb0a
Signed-off-by: Matthew Rice <quic_mrice@quicinc.com>
This commit is contained in:
Matthew Rice
2022-03-02 16:32:50 -08:00
committed by Gerrit - the friendly Code Review server
parent 018369d65f
commit 9d7405ec04
2 changed files with 5 additions and 3 deletions

View File

@@ -758,7 +758,9 @@ static int wsa_dev_mode_put(struct snd_kcontrol *kcontrol,
dev_dbg(component->dev, "%s: Dev Mode current: %d, new: %d = %ld\n",
__func__, wsa884x->dev_mode, dev_mode);
if (dev_mode >= SPEAKER && dev_mode <= RECEIVER) {
/* Check if input parameter is in range */
if ((wsa884x->dev_mode + (wsa884x->dev_index - 1) * 2) <
(MAX_DEV_MODE * 2)) {
wsa884x->dev_mode = dev_mode;
wsa884x->system_gain = wsa884x->sys_gains[
wsa884x->dev_mode + (wsa884x->dev_index - 1) * 2];