ASoC: wm_adsp: Fix uninitialized variable warnings
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Mon, 11 Jan 2021 13:38:25 +0000 (13:38 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 11 Jan 2021 14:03:53 +0000 (14:03 +0000)
commitfe9989fb25b0cea6414e72e0514c70ed8b158c28
tree0657372464106820a9052f0f5636825c00a2378e
parent4eeed5f40354735c4e68e71904db528ed19c9cbb
ASoC: wm_adsp: Fix uninitialized variable warnings

wm_adsp_read_data_word() used if (ret) to check for an error from
wm_adsp_read_raw_data_block(). While this is perfectly valid,
wm_adsp_read_raw_data_block() itself uses if (ret < 0) and three
calls to wm_adsp_read_data_word() also use if (ret < 0).

This creates an error check chain like this:

  1st) if (ret < 0) return ret;
  2nd) if (ret) return ret;
  3rd) if (ret < 0) ...

This can confuse the compiler into thinking that there are possible
returns > 0 from the middle if() that are not handled by the final
if(). If this was true it would lead to using uninitialized variables
later in the outer function.

Fix this by changing the test in wm_adsp_read_data_word() to be
if (ret < 0).

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210111133825.8758-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c