Skip to content

Commit 85f8d00

Browse files
brooniegregkh
authored andcommitted
ASoC: meson: g12a-toacodec: Validate written enum values
[ Upstream commit 3150b70e944ead909260285dfb5707d0bedcf87b ] When writing to an enum we need to verify that the value written is valid for the enumeration, the helper function snd_soc_item_enum_to_val() doesn't do it since it needs to return an unsigned (and in any case we'd need to check the return value). Fixes: af2618a ("ASoC: meson: g12a: add internal DAC glue driver") Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20240103-meson-enum-val-v1-1-424af7a8fb91@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 21ecce2 commit 85f8d00

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/soc/meson/g12a-toacodec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
4646
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
4747
unsigned int mux, changed;
4848

49+
if (ucontrol->value.enumerated.item[0] >= e->items)
50+
return -EINVAL;
51+
4952
mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
5053
changed = snd_soc_component_test_bits(component, e->reg,
5154
CTRL0_DAT_SEL,

0 commit comments

Comments
 (0)