Skip to content

Commit fc563aa

Browse files
Stephen Leebroonie
authored andcommitted
ASoC: ops: Fix wraparound for mask in snd_soc_get_volsw
In snd_soc_info_volsw(), mask is generated by figuring out the index of the most significant bit set in max and converting the index to a bitmask through bit shift 1. Unintended wraparound occurs when max is an integer value with msb bit set. Since the bit shift value 1 is treated as an integer type, the left shift operation will wraparound and set mask to 0 instead of all 1's. In order to fix this, we type cast 1 as `1ULL` to prevent the wraparound. Fixes: 7077148 ("ASoC: core: Split ops out of soc-core.c") Signed-off-by: Stephen Lee <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4af565d commit fc563aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/soc/soc-ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
263263
int max = mc->max;
264264
int min = mc->min;
265265
int sign_bit = mc->sign_bit;
266-
unsigned int mask = (1 << fls(max)) - 1;
266+
unsigned int mask = (1ULL << fls(max)) - 1;
267267
unsigned int invert = mc->invert;
268268
int val;
269269
int ret;

0 commit comments

Comments
 (0)