提交 b2b8dcff 编写于 作者: A Alexey Khoroshilov 提交者: Zheng Zengkai

ASoC: max98090: Move check for invalid values before casting in max98090_put_enab_tlv()

stable inclusion
from stable-v5.10.121
commit 7386f69041594f186045e01d5f2ca2f675a30916
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7386f69041594f186045e01d5f2ca2f675a30916

--------------------------------

[ Upstream commit f7a34446 ]

Validation of signed input should be done before casting to unsigned int.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: NAlexey Khoroshilov <khoroshilov@ispras.ru>
Suggested-by: NMark Brown <broonie@kernel.org>
Fixes: 2fbe467b ("ASoC: max98090: Reject invalid values in custom control put()")
Link: https://lore.kernel.org/r/1652999486-29653-1-git-send-email-khoroshilov@ispras.ruSigned-off-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 c8470dce
...@@ -393,7 +393,8 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, ...@@ -393,7 +393,8 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int mask = (1 << fls(mc->max)) - 1; unsigned int mask = (1 << fls(mc->max)) - 1;
unsigned int sel = ucontrol->value.integer.value[0]; int sel_unchecked = ucontrol->value.integer.value[0];
unsigned int sel;
unsigned int val = snd_soc_component_read(component, mc->reg); unsigned int val = snd_soc_component_read(component, mc->reg);
unsigned int *select; unsigned int *select;
...@@ -413,8 +414,9 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, ...@@ -413,8 +414,9 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
val = (val >> mc->shift) & mask; val = (val >> mc->shift) & mask;
if (sel < 0 || sel > mc->max) if (sel_unchecked < 0 || sel_unchecked > mc->max)
return -EINVAL; return -EINVAL;
sel = sel_unchecked;
*select = sel; *select = sel;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册