diff mbox series

[2/3] ASoC: mt6358: Validate Wake on Voice 2 writes

Message ID 20230224-asoc-mt6358-quick-fixes-v1-2-747d9186be4b@kernel.org (mailing list archive)
State Accepted
Commit 8e847a43c28fca0aaa11fba8f91da7dfd9d6936f
Headers show
Series ASoC: mt6358: Fixes from an initial glance at a kselftest run | expand

Commit Message

Mark Brown Feb. 26, 2023, 12:47 p.m. UTC
Currently the Wake on Voice 2 control accepts and stores any value written
but it reports that only 0 and 1 are valid values. Reject any out of range
values written by userspace.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/mt6358.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

AngeloGioacchino Del Regno Feb. 27, 2023, 8:55 a.m. UTC | #1
Il 26/02/23 13:47, Mark Brown ha scritto:
> Currently the Wake on Voice 2 control accepts and stores any value written
> but it reports that only 0 and 1 are valid values. Reject any out of range
> values written by userspace.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
diff mbox series

Patch

diff --git a/sound/soc/codecs/mt6358.c b/sound/soc/codecs/mt6358.c
index 9004377461f7..89d0dcb2635b 100644
--- a/sound/soc/codecs/mt6358.c
+++ b/sound/soc/codecs/mt6358.c
@@ -560,6 +560,9 @@  static int mt6358_put_wov(struct snd_kcontrol *kcontrol,
 	struct mt6358_priv *priv = snd_soc_component_get_drvdata(c);
 	int enabled = ucontrol->value.integer.value[0];
 
+	if (enabled < 0 || enabled > 1)
+		return -EINVAL;
+
 	if (priv->wov_enabled != enabled) {
 		if (enabled)
 			mt6358_enable_wov_phase2(priv);