Skip to content

Commit

Permalink
ASoC: wm_adsp: Correct control read size when parsing compressed buffer
Browse files Browse the repository at this point in the history
commit a887f9c upstream.

When parsing the compressed stream the whole buffer descriptor is
now read in a single cs_dsp_coeff_read_ctrl; on older firmwares
this descriptor is just 4 bytes but on more modern firmwares it is
24 bytes. The current code reads the full 24 bytes regardless, this
was working but reading junk for the last 20 bytes. However commit
f444da3 ("firmware: cs_dsp: Add offset to cs_dsp read/write")
added a size check into cs_dsp_coeff_read_ctrl, causing the older
firmwares to now return an error.

Update the code to only read the amount of data appropriate for
the firmware loaded.

Fixes: 04ae085 ("ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220210172053.22782-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
charleskeepax authored and gregkh committed Feb 23, 2022
1 parent bfe2e9a commit d24f874
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/soc/codecs/wm_adsp.c
Expand Up @@ -1448,7 +1448,8 @@ static int wm_adsp_buffer_parse_coeff(struct cs_dsp_coeff_ctl *cs_ctl)
int ret, i;

for (i = 0; i < 5; ++i) {
ret = cs_dsp_coeff_read_ctrl(cs_ctl, &coeff_v1, sizeof(coeff_v1));
ret = cs_dsp_coeff_read_ctrl(cs_ctl, &coeff_v1,
min(cs_ctl->len, sizeof(coeff_v1)));
if (ret < 0)
return ret;

Expand Down

0 comments on commit d24f874

Please sign in to comment.