* [PATCH][next] ASoC: codecs: wcd: Fix a less than zero check on an u32 array element
@ 2025-09-24 10:33 Colin Ian King
2025-09-24 10:37 ` Srinivas Kandagatla
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2025-09-24 10:33 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Dmitry Baryshkov,
Srinivas Kandagatla, linux-sound
Cc: kernel-janitors, linux-kernel
Currently the error check from the call to wcd_get_micbias_val is always
false because an u32 unsigned int in common->micb_vout[i] is being used to
to perform the less than zero error check. Fix this by using the int
variable ret to perform the check.
Fixes: 4f16b6351bbf ("ASoC: codecs: wcd: add common helper for wcd codecs")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
sound/soc/codecs/wcd-common.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wcd-common.c b/sound/soc/codecs/wcd-common.c
index 9bbfda828377..9fd3965ed540 100644
--- a/sound/soc/codecs/wcd-common.c
+++ b/sound/soc/codecs/wcd-common.c
@@ -65,9 +65,12 @@ int wcd_dt_parse_micbias_info(struct wcd_common *common)
int 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)
+ int ret;
+
+ ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
+ if (ret < 0)
return -EINVAL;
+ common->micb_vout[i] = ret;
}
return 0;
--
2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][next] ASoC: codecs: wcd: Fix a less than zero check on an u32 array element
2025-09-24 10:33 [PATCH][next] ASoC: codecs: wcd: Fix a less than zero check on an u32 array element Colin Ian King
@ 2025-09-24 10:37 ` Srinivas Kandagatla
0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2025-09-24 10:37 UTC (permalink / raw)
To: Colin Ian King, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Dmitry Baryshkov, linux-sound
Cc: kernel-janitors, linux-kernel
On 9/24/25 11:33 AM, Colin Ian King wrote:
> Currently the error check from the call to wcd_get_micbias_val is always
> false because an u32 unsigned int in common->micb_vout[i] is being used to
> to perform the less than zero error check. Fix this by using the int
> variable ret to perform the check.
>
> Fixes: 4f16b6351bbf ("ASoC: codecs: wcd: add common helper for wcd codecs")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
Dan Carpenter sent exactly same fix yesterday:
https://www.spinics.net/lists/kernel/msg5855359.html
--srini
> sound/soc/codecs/wcd-common.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/wcd-common.c b/sound/soc/codecs/wcd-common.c
> index 9bbfda828377..9fd3965ed540 100644
> --- a/sound/soc/codecs/wcd-common.c
> +++ b/sound/soc/codecs/wcd-common.c
> @@ -65,9 +65,12 @@ int wcd_dt_parse_micbias_info(struct wcd_common *common)
> int 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)
> + int ret;
> +
> + ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
> + if (ret < 0)
> return -EINVAL;
> + common->micb_vout[i] = ret;
> }
>
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-24 10:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-24 10:33 [PATCH][next] ASoC: codecs: wcd: Fix a less than zero check on an u32 array element Colin Ian King
2025-09-24 10:37 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®