[PATCH 2/6] ASoC: aw88399: fix error checks in aw_dev_fw_crc_check()
From: Marco Giunta
Date: Thu Nov 26 2026 - 16:29:11 EST
aw_dev_fw_crc_check() does not store the return value of the regmap_read()
of the CRC result, so the error check after it tests the earlier
regmap_update_bits() call instead. A failed read therefore goes unnoticed,
and the CRC result is taken from an uninitialized variable.
Store the return value of the read, and check the regmap_update_bits()
call immediately, before sleeping and reading the result, as the aw883xx
vendor driver does.
Fixes: 8ade6cc7e261 ("ASoC: codecs: Add aw88399 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@xxxxxxxxxx>
---
sound/soc/codecs/aw88399-lib.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index f2e2c88f5ec0..20e809035107 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -437,11 +437,13 @@ static int aw_dev_fw_crc_check(struct aw_device *aw_dev)
/* enable fw crc check */
ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG,
~AW88399_CRC_CODE_EN_MASK, AW88399_CRC_CODE_EN_ENABLE_VALUE);
+ if (ret)
+ return ret;
usleep_range(AW88399_2000_US, AW88399_2000_US + 10);
/* read crc check result */
- regmap_read(aw_dev->regmap, AW88399_HAGCST_REG, ®_val);
+ ret = regmap_read(aw_dev->regmap, AW88399_HAGCST_REG, ®_val);
if (ret)
return ret;
--
2.56.1