History

ASoC: fsl_easrc: Check the variable range in fsl_easrc_iec958_put_bits()

Add check of input value's range in fsl_easrc_iec958_put_bits(), otherwise the wrong value may be written from user space.

Shengjiu Wang committed 7 months ago

Commit 00541b81 parent 64a496b1 file · +3 −0Browse files

Unified · Split

sound/soc/fsl/fsl_easrc.c+3−0
@@ -54,6 +54,9 @@ static int fsl_easrc_iec958_put_bits(struct snd_kcontrol *kcontrol, · 53 unmodified lines
54 unsigned int regval = ucontrol->value.integer.value[0];54 unsigned int regval = ucontrol->value.integer.value[0];
55 int ret;55 int ret;
56 56
57 if (regval < EASRC_WIDTH_16_BIT || regval > EASRC_WIDTH_24_BIT)
58 return -EINVAL;
59
57 ret = (easrc_priv->bps_iec958[mc->regbase] != regval);60 ret = (easrc_priv->bps_iec958[mc->regbase] != regval);
58 61
59 easrc_priv->bps_iec958[mc->regbase] = regval;62 easrc_priv->bps_iec958[mc->regbase] = regval;