mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
ASoC: change mask in snd_soc_get/put_volsw_sx to unsigned int
If the result of (min + max) is negative in functions snd_soc_get_volsw_sx() or snd_soc_put_volsw_sx(), there will be an overflow for the variable 'mask'. UBSAN: Undefined behaviour in sound/soc/soc-ops.c:382:6 signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' Fix this by updating the variable type of 'mask' to unsigned int. Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
cb2cf0de11
commit
b9f902b7fd
1 changed files with 2 additions and 2 deletions
|
@ -378,7 +378,7 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
|
||||||
unsigned int rshift = mc->rshift;
|
unsigned int rshift = mc->rshift;
|
||||||
int max = mc->max;
|
int max = mc->max;
|
||||||
int min = mc->min;
|
int min = mc->min;
|
||||||
int mask = (1 << (fls(min + max) - 1)) - 1;
|
unsigned int mask = (1 << (fls(min + max) - 1)) - 1;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
|
||||||
unsigned int rshift = mc->rshift;
|
unsigned int rshift = mc->rshift;
|
||||||
int max = mc->max;
|
int max = mc->max;
|
||||||
int min = mc->min;
|
int min = mc->min;
|
||||||
int mask = (1 << (fls(min + max) - 1)) - 1;
|
unsigned int mask = (1 << (fls(min + max) - 1)) - 1;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned int val, val_mask, val2 = 0;
|
unsigned int val, val_mask, val2 = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue