diff options
| author | Tom Rix <[email protected]> | 2021-04-30 14:21:17 +0000 |
|---|---|---|
| committer | Mark Brown <[email protected]> | 2021-05-10 16:06:06 +0000 |
| commit | 58f01c7fc81baced84f237554d56847e17b5d730 (patch) | |
| tree | 327087ed42d68cbbcb9a2a22fd545bfb204a0e87 /sound/soc/codecs/lpass-wsa-macro.c | |
| parent | ASoC: rt286: Remove redundant assignment to d_len_code (diff) | |
| download | kernel-58f01c7fc81baced84f237554d56847e17b5d730.tar.gz kernel-58f01c7fc81baced84f237554d56847e17b5d730.zip | |
ASoC: codecs: lpass-wsa-macro: handle unexpected input
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 <[email protected]>
Reviewed-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Diffstat (limited to 'sound/soc/codecs/lpass-wsa-macro.c')
| -rw-r--r-- | sound/soc/codecs/lpass-wsa-macro.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 1a7fa5492f28..d3ac318fd6b6 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -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]) { |
