* [PATCH 3/4] ASoC: fsl: fsl_audmix: Validate written enum values [not found] <20260609124317.38046-1-sammiee5311@gmail.com> @ 2026-06-09 12:43 ` HyeongJun An 2026-06-12 10:36 ` Shengjiu Wang 0 siblings, 1 reply; 2+ messages in thread From: HyeongJun An @ 2026-06-09 12:43 UTC (permalink / raw) To: Mark Brown, Liam Girdwood Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel, HyeongJun An, Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Viorel Suman, linuxppc-dev fsl_audmix_put_mix_clk_src() and fsl_audmix_put_out_src() convert the user-provided enum item with snd_soc_enum_item_to_val() before checking whether the item is within the enum's item count. The generic snd_soc_put_enum_double() helper performs that validation, but these callbacks use the converted value first: the clock-source path tests it with BIT(), and the output-source path indexes the prms transition table with it. Reject out-of-range enum items before converting them. Fixes: be1df61cf06e ("ASoC: fsl: Add Audio Mixer CPU DAI driver") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: HyeongJun An <sammiee5311@gmail.com> --- sound/soc/fsl/fsl_audmix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c index 40a3b7432174..f819f33ec46b 100644 --- a/sound/soc/fsl/fsl_audmix.c +++ b/sound/soc/fsl/fsl_audmix.c @@ -117,6 +117,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol, unsigned int *item = ucontrol->value.enumerated.item; unsigned int reg_val, val, mix_clk; + if (item[0] >= e->items) + return -EINVAL; + /* Get current state */ reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR); mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK) @@ -157,6 +160,9 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol, unsigned int reg_val, val, mask = 0, ctr = 0; int ret; + if (item[0] >= e->items) + return -EINVAL; + /* Get current state */ reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR); -- 2.43.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] ASoC: fsl: fsl_audmix: Validate written enum values 2026-06-09 12:43 ` [PATCH 3/4] ASoC: fsl: fsl_audmix: Validate written enum values HyeongJun An @ 2026-06-12 10:36 ` Shengjiu Wang 0 siblings, 0 replies; 2+ messages in thread From: Shengjiu Wang @ 2026-06-12 10:36 UTC (permalink / raw) To: HyeongJun An Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel, Xiubo Li, Fabio Estevam, Nicolin Chen, Viorel Suman, linuxppc-dev On Tue, Jun 9, 2026 at 8:47 PM HyeongJun An <sammiee5311@gmail.com> wrote: > > fsl_audmix_put_mix_clk_src() and fsl_audmix_put_out_src() > convert the user-provided enum item with snd_soc_enum_item_to_val() > before checking whether the item is within the enum's item count. > > The generic snd_soc_put_enum_double() helper performs that > validation, but these callbacks use the converted value first: the > clock-source path tests it with BIT(), and the output-source path > indexes the prms transition table with it. > > Reject out-of-range enum items before converting them. > > Fixes: be1df61cf06e ("ASoC: fsl: Add Audio Mixer CPU DAI driver") > Assisted-by: Claude:claude-opus-4-8 > Signed-off-by: HyeongJun An <sammiee5311@gmail.com> Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com> Best regards Shengjiu Wang > --- > sound/soc/fsl/fsl_audmix.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c > index 40a3b7432174..f819f33ec46b 100644 > --- a/sound/soc/fsl/fsl_audmix.c > +++ b/sound/soc/fsl/fsl_audmix.c > @@ -117,6 +117,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol, > unsigned int *item = ucontrol->value.enumerated.item; > unsigned int reg_val, val, mix_clk; > > + if (item[0] >= e->items) > + return -EINVAL; > + > /* Get current state */ > reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR); > mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK) > @@ -157,6 +160,9 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol, > unsigned int reg_val, val, mask = 0, ctr = 0; > int ret; > > + if (item[0] >= e->items) > + return -EINVAL; > + > /* Get current state */ > reg_val = snd_soc_component_read(comp, FSL_AUDMIX_CTR); > > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-12 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260609124317.38046-1-sammiee5311@gmail.com>
2026-06-09 12:43 ` [PATCH 3/4] ASoC: fsl: fsl_audmix: Validate written enum values HyeongJun An
2026-06-12 10:36 ` Shengjiu Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox