[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <647db8c8-2ee0-0dee-51e5-41120566bb5e@linaro.org>
Date: Fri, 30 Apr 2021 17:36:48 +0100
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: trix@...hat.com, bgoswami@...eaurora.org, lgirdwood@...il.com,
broonie@...nel.org, perex@...ex.cz, tiwai@...e.com
Cc: alsa-devel@...a-project.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] ASoC: codecs: lpass-wsa-macro: handle unexpected input
Thanks Tom for fixing this.
On 30/04/2021 15:21, trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
>
> 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@...hat.com>
> ---
> v2:
> - handle the input error, keep switch
> ---
> sound/soc/codecs/lpass-wsa-macro.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> 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;
With the existing code we should never even touch this default path,
However the changes look safe to me,
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
--srini
> }
>
> if (wsa->ec_hq[ec_tx]) {
>
Powered by blists - more mailing lists