linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm_adsp: Fix uninitialized variable warnings
@ 2021-01-11 13:38 Richard Fitzgerald
  2021-01-11 16:27 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2021-01-11 13:38 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, linux-kernel, Richard Fitzgerald

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>
---
 sound/soc/codecs/wm_adsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f8ad768364c2..1fc7bc1970ea 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3694,7 +3694,7 @@ static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type,
 	int ret;
 
 	ret = wm_adsp_read_raw_data_block(dsp, mem_type, mem_addr, 1, &raw);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
 	*data = be32_to_cpu(raw) & 0x00ffffffu;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Fix uninitialized variable warnings
  2021-01-11 13:38 [PATCH] ASoC: wm_adsp: Fix uninitialized variable warnings Richard Fitzgerald
@ 2021-01-11 16:27 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2021-01-11 16:27 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: alsa-devel, linux-kernel, patches

On Mon, 11 Jan 2021 13:38:25 +0000, Richard Fitzgerald wrote:
> 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:
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: wm_adsp: Fix uninitialized variable warnings
      commit: fe9989fb25b0cea6414e72e0514c70ed8b158c28

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-11 16:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 13:38 [PATCH] ASoC: wm_adsp: Fix uninitialized variable warnings Richard Fitzgerald
2021-01-11 16:27 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).