Skip to contentSkip to conversation

ASoC: codecs: wcd-common: fix signedness bug in wcd_dt_parse_micbias_info()

PATCH In review Dan Carpenter 3 participants 3 messages Sep 23, 2025 – Sep 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: codecs: wcd-common: fix signedness bug in wcd_dt_parse_micbias_info()

The error handling does not work because common->micb_vout[] is an array of u32. We need a signed variable to store negative error codes.

Fixes 4f16b6351bbf ("ASoC: codecs: wcd: add common helper for wcd codecs")
---
 sound/soc/codecs/wcd-common.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/codecs/wcd-common.c +5 -4
index 9bbfda828377..9016e974582f 100644
@@ -62,12 +62,13 @@ static int wcd_get_micbias_val(struct device *dev, int micb_num, u32 *micb_mv)
 
 int wcd_dt_parse_micbias_info(struct wcd_common *common)
 {
-	int i;
+	int ret, i;
 
 	for (i = 0; i < common->max_bias; i++) {
-		common->micb_vout[i] = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
-		if (common->micb_vout[i] < 0)
-			return -EINVAL;
+		ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
+		if (ret < 0)
+			return ret;
+		common->micb_vout[i] = ret;
 	}
 
 	return 0;
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The error handling does not work because common->micb_vout[] is an array of u32. We need a signed variable to store negative error codes.

Fixes 4f16b6351bbf ("ASoC: codecs: wcd: add common helper for wcd codecs")

---

Thanks Dan for fixing this,

--srini

Quoted 25 lines
 sound/soc/codecs/wcd-common.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/codecs/wcd-common.c +5 -4
index 9bbfda828377..9016e974582f 100644
@@ -62,12 +62,13 @@ static int wcd_get_micbias_val(struct device *dev, int micb_num, u32 *micb_mv)
 
 int wcd_dt_parse_micbias_info(struct wcd_common *common)
 {
-	int i;
+	int ret, i;
 
 	for (i = 0; i < common->max_bias; i++) {
-		common->micb_vout[i] = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
-		if (common->micb_vout[i] < 0)
-			return -EINVAL;
+		ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
+		if (ret < 0)
+			return ret;
+		common->micb_vout[i] = ret;
 	}
 
 	return 0;
maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The error handling does not work because common->micb_vout[] is an array of u32. We need a signed variable to store negative error codes.

Applied to

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

Thanks!

[1/1] ASoC: codecs: wcd-common: fix signedness bug in wcd_dt_parse_micbias_info()

      commit: dc64b3d42cb361d4b39eb7cc73037fec52ef9676

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