Skip to content

Commit

Permalink
ASoC: codecs: lpass-wsa-macro: handle unexpected input
Browse files Browse the repository at this point in the history
Static analysis reports this problem

lpass-wsa-macro.c:1732:6: warning: Array subscript is undefined
        if (wsa->ec_hq[ec_tx]) {
            ^~~~~~~~~~~~~~~~~

The happens because 'ec_tx' is never initialized and there is
no default in switch statement that sets ec_tx.  Add a default
case that returns an error before the array is accessed.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210430142117.3272772-1-trix@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Tom Rix authored and Mark Brown committed May 10, 2021
1 parent 1d122dd commit 58f01c7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/soc/codecs/lpass-wsa-macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,10 @@ static int wsa_macro_enable_echo(struct snd_soc_dapm_widget *w,
val = val & CDC_WSA_RX_MIX_TX1_SEL_MASK;
ec_tx = (val >> CDC_WSA_RX_MIX_TX1_SEL_SHFT) - 1;
break;
default:
dev_err(component->dev, "%s: Invalid shift %u\n",
__func__, w->shift);
return -EINVAL;
}

if (wsa->ec_hq[ec_tx]) {
Expand Down

0 comments on commit 58f01c7

Please sign in to comment.