[PATCH 2/2] ASoC: ops: Fix signedness bug in snd_soc_put_volsw_sx()

Dan Carpenter dan.carpenter at oracle.com
Fri Jan 28 12:20:42 CET 2022


The "val" variable needs to be signed for the checking to work
correctly.

Fixes: 4f1e50d6a9cf ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
---
 sound/soc/soc-ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
index 0091fa96eb48..a615316a06ff 100644
--- a/sound/soc/soc-ops.c
+++ b/sound/soc/soc-ops.c
@@ -422,7 +422,8 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 	int min = mc->min;
 	unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
 	int err = 0;
-	unsigned int val, val_mask;
+	unsigned int val_mask;
+	int val;
 
 	val = ucontrol->value.integer.value[0];
 	if (mc->platform_max && val > mc->platform_max)
-- 
2.20.1



More information about the Alsa-devel mailing list