Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/aNKEZ3VqJ8js208v@stanley.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dan Carpenter and committed by
Mark Brown
dc64b3d4 2cc67105

+5 -4
+5 -4
sound/soc/codecs/wcd-common.c
··· 62 62 63 63 int wcd_dt_parse_micbias_info(struct wcd_common *common) 64 64 { 65 - int i; 65 + int ret, i; 66 66 67 67 for (i = 0; i < common->max_bias; i++) { 68 - common->micb_vout[i] = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]); 69 - if (common->micb_vout[i] < 0) 70 - return -EINVAL; 68 + ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]); 69 + if (ret < 0) 70 + return ret; 71 + common->micb_vout[i] = ret; 71 72 } 72 73 73 74 return 0;