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:
@@ -1373,7 +1373,7 @@ static int lpass_cdc_wsa_macro_config_compander(struct snd_soc_component *compon
|
||||
if (!lpass_cdc_wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (comp >= LPASS_CDC_WSA_MACRO_COMP_MAX) {
|
||||
if (comp >= LPASS_CDC_WSA_MACRO_COMP_MAX || comp < 0) {
|
||||
dev_err(component->dev, "%s: Invalid compander value: %d\n",
|
||||
__func__, comp);
|
||||
return -EINVAL;
|
||||
@@ -1386,6 +1386,8 @@ static int lpass_cdc_wsa_macro_config_compander(struct snd_soc_component *compon
|
||||
return 0;
|
||||
|
||||
mode = wsa_priv->comp_mode[comp];
|
||||
if (mode >= G_MAX_DB || mode < 0)
|
||||
mode = 0;
|
||||
comp_ctl0_reg = LPASS_CDC_WSA_COMPANDER0_CTL0 +
|
||||
(comp * LPASS_CDC_WSA_MACRO_RX_COMP_OFFSET);
|
||||
comp_ctl8_reg = LPASS_CDC_WSA_COMPANDER0_CTL8 +
|
||||
@@ -2416,7 +2418,11 @@ static int lpass_cdc_wsa_macro_comp_mode_put(struct snd_kcontrol *kcontrol,
|
||||
idx = LPASS_CDC_WSA_MACRO_COMP1;
|
||||
if (strnstr(kcontrol->id.name, "RX1", sizeof("WSA_RX1")))
|
||||
idx = LPASS_CDC_WSA_MACRO_COMP2;
|
||||
wsa_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
|
||||
|
||||
if (ucontrol->value.integer.value[0] < G_MAX_DB && ucontrol->value.integer.value[0] >= 0)
|
||||
wsa_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
|
||||
else
|
||||
return 0;
|
||||
|
||||
dev_dbg(component->dev, "%s: comp_mode = %d\n", __func__,
|
||||
wsa_priv->comp_mode[idx]);
|
||||
|
Reference in New Issue
Block a user