asoc: update out of bound check for comp_mode.

updated the out of bound check for comp_mode
if any such occurence happens setting it to default mode.

Change-Id: Ie4a7275d45af6a96f1a2ec4b6ece6dc7a5dca464
Signed-off-by: Ganapathiraju Sarath Varma <quic_ganavarm@quicinc.com>
This commit is contained in:
Ganapathiraju Sarath Varma
2022-07-13 13:34:44 +05:30
parent 49b2306433
commit c7d5b69be6
2 changed files with 22 additions and 3 deletions

View File

@@ -1381,10 +1381,18 @@ static int lpass_cdc_wsa2_macro_config_compander(struct snd_soc_component *compo
dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n",
__func__, event, comp + 1, wsa2_priv->comp_enabled[comp]);
if (comp >= LPASS_CDC_WSA2_MACRO_COMP_MAX || comp < 0) {
dev_err(component->dev, "%s: Invalid compander value: %d\n",
__func__, comp);
return -EINVAL;
}
if (!wsa2_priv->comp_enabled[comp])
return 0;
mode = wsa2_priv->comp_mode[comp];
if (mode >= G_MAX_DB || mode < 0)
mode = 0;
comp_ctl0_reg = LPASS_CDC_WSA2_COMPANDER0_CTL0 +
(comp * LPASS_CDC_WSA2_MACRO_RX_COMP_OFFSET);
comp_ctl8_reg = LPASS_CDC_WSA2_COMPANDER0_CTL8 +
@@ -2415,7 +2423,12 @@ static int lpass_cdc_wsa2_macro_comp_mode_put(struct snd_kcontrol *kcontrol,
idx = LPASS_CDC_WSA2_MACRO_COMP1;
if (strnstr(kcontrol->id.name, "RX1", sizeof("WSA2_RX1")))
idx = LPASS_CDC_WSA2_MACRO_COMP2;
wsa2_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
if (ucontrol->value.integer.value[0] < G_MAX_DB &&
ucontrol->value.integer.value[0] >= 0)
wsa2_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
else
return 0;
dev_dbg(component->dev, "%s: comp_mode = %d\n", __func__,
wsa2_priv->comp_mode[idx]);