summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-01-03 18:34:01 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-15 18:51:16 +0100
commitf74281f241ffa15d5a1e41ba34518991e086e5e6 (patch)
tree316eeeda4955727c79863ab2c7ee1619669366b1
parent947db598acb89e63542a1a66a005cef539f937eb (diff)
downloadlinux-f74281f241ffa15d5a1e41ba34518991e086e5e6.tar.gz
linux-f74281f241ffa15d5a1e41ba34518991e086e5e6.tar.bz2
linux-f74281f241ffa15d5a1e41ba34518991e086e5e6.zip
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: af2618a2eee8 ("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>
-rw-r--r--sound/soc/meson/g12a-toacodec.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index 1dfee1396843..10a2ff1ecf33 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -71,6 +71,9 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int mux, reg;
+ if (ucontrol->value.enumerated.item[0] >= e->items)
+ return -EINVAL;
+
mux = snd_soc_enum_item_to_val(e, ucontrol->value.enumerated.item[0]);
regmap_field_read(priv->field_dat_sel, &reg);