Skip to content

Commit

Permalink
ASoC: wm_adsp: Fix uninitialized variable warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
rfvirgil authored and broonie committed Jan 11, 2021
1 parent 4eeed5f commit fe9989f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/codecs/wm_adsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fe9989f

Please sign in to comment.