From: sashiko-bot@kernel.org
To: "Mohammad Rafi Shaik" <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 5/9] ASoC: qcom: lpass-va-macro: Add SoundWire microphone support
Date: Mon, 30 Nov 2026 21:47:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-242041@kernel.org> (raw)
In-Reply-To: <20261201-add_shikra_support-v8-5-5e56d0ad3810@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: lpass-va-macro: unvalidated index in
va_macro_put_dec_mux()
--
commit b829bf6e53b2485766d0cdfdea3eb6d248f500f4
Author: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
ASoC: qcom: lpass-va-macro: Add SoundWire microphone support
This commit adds DAPM widgets, routes, and decimator mux callbacks to
support routing SoundWire microphone inputs to the VA decimators.
> diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
> index 399468ebea0bf..87532e4da5d20 100644
> --- a/sound/soc/codecs/lpass-va-macro.c
> +++ b/sound/soc/codecs/lpass-va-macro.c
[ ... ]
> @@ -755,10 +771,69 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
> return -EINVAL;
> }
>
> - if (val != 0)
> + /*
> + * SMIC enums use shift 0 (lower nibble of CFG0), DMIC enums use
> + * shift 4 (upper nibble of CFG0). Use e->shift_l to distinguish them
> + * without relying on widget name comparisons.
> + */
> + smic_mux = (e->shift_l == 0);
> +
> + /*
> + * Both muxes feed the same decimator and share ADC_DMIC_SEL, so only
> + * the one the decimator is routed through may program it. A write to
> + * the mux that is not part of the active path would otherwise switch
> + * the input domain of a running capture.
> + */
> + if (val != 0 && smic_mux == is_amic_enabled(component, decimator))
> snd_soc_component_update_bits(component, mic_sel_reg,
> CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK,
> - CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
> + smic_mux ? CDC_VA_TX_PATH_ADC_DMIC_SEL_ADC :
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
> +
> + return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
> +}
> +
> +static int va_macro_put_dec_mux(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol);
> + struct snd_soc_component *component =
> + snd_soc_dapm_to_component(widget->dapm);
> + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> + unsigned int val;
> + u16 mic_sel_reg;
> +
> + val = ucontrol->value.enumerated.item[0];
> +
> + switch (e->reg) {
> + case CDC_VA_INP_MUX_ADC_MUX0_CFG1:
> + mic_sel_reg = CDC_VA_TX0_TX_PATH_CFG0;
> + break;
> + case CDC_VA_INP_MUX_ADC_MUX1_CFG1:
> + mic_sel_reg = CDC_VA_TX1_TX_PATH_CFG0;
> + break;
> + case CDC_VA_INP_MUX_ADC_MUX2_CFG1:
> + mic_sel_reg = CDC_VA_TX2_TX_PATH_CFG0;
> + break;
> + case CDC_VA_INP_MUX_ADC_MUX3_CFG1:
> + mic_sel_reg = CDC_VA_TX3_TX_PATH_CFG0;
> + break;
> + default:
> + dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
> + __func__, e->reg);
> + return -EINVAL;
> + }
> +
> + /*
> + * This mux selects the input domain of the decimator, so ADC_DMIC_SEL
> + * has to follow it. When both sub muxes have an input selected the
> + * decimator stays powered across the switch, so va_macro_enable_dec()
> + * does not run and would leave ADC_DMIC_SEL on the previous domain.
> + */
> + snd_soc_component_update_bits(component, mic_sel_reg,
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK,
> + val ? CDC_VA_TX_PATH_ADC_DMIC_SEL_ADC :
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
>
> return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
> }
[Severity: Medium]
Can an out-of-range enum value (val >= e->items) update mic_sel_reg in
va_macro_put_dec_mux() and va_macro_put_dec_enum() before
snd_soc_dapm_put_enum_double() validates item[0] and rejects the write
with -EINVAL?
When CONFIG_SND_CTL_INPUT_VALIDATION is disabled, snd_ctl_elem_write()
leaves bounds checking to the put callback. If VA DECn MUX is set to 0
(VA_DMIC) and userspace writes an invalid index >= 2,
va_macro_put_dec_mux() switches ADC_DMIC_SEL to ADC while
snd_soc_dapm_put_enum_double() returns -EINVAL without updating
CDC_VA_INP_MUX_ADC_MUXn_CFG1, leaving ADC_DMIC_SEL out of sync with the
active mux state and breaking DMIC capture. Checking val >= e->items
before updating mic_sel_reg (as tx_macro_put_dec_enum() does in
lpass-tx-macro.c) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-add_shikra_support-v8-0-5e56d0ad3810@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-11-30 21:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 21:33 [PATCH v8 0/9] ASoC: qcom: Add shikra and Hawi LPASS macro support Mohammad Rafi Shaik
2026-11-30 21:33 ` [PATCH v8 1/9] ASoC: dt-bindings: qcom: Add Shikra RX and VA macro codecs Mohammad Rafi Shaik
2026-11-30 21:33 ` [PATCH v8 2/9] ASoC: qcom: lpass-macro-common: Add missing v2.9 version string Mohammad Rafi Shaik
2026-11-30 21:33 ` [PATCH v8 3/9] ASoC: qcom: lpass-rx-macro: Add shikra compatible Mohammad Rafi Shaik
2026-11-30 21:33 ` [PATCH v8 4/9] ASoC: qcom: lpass-va-macro: " Mohammad Rafi Shaik
2026-11-30 21:46 ` sashiko-bot
2026-11-30 21:34 ` [PATCH v8 5/9] ASoC: qcom: lpass-va-macro: Add SoundWire microphone support Mohammad Rafi Shaik
2026-11-30 21:47 ` sashiko-bot [this message]
2026-11-30 21:34 ` [PATCH v8 6/9] ASoC: dt-bindings: qcom: Add Hawi LPASS macro codecs Mohammad Rafi Shaik
2026-11-30 21:34 ` [PATCH v8 7/9] ASoC: dt-bindings: qcom: Add Maili " Mohammad Rafi Shaik
2026-11-30 21:34 ` [PATCH v8 8/9] ASoC: qcom: lpass-tx-macro: Add support for Hawi Mohammad Rafi Shaik
2026-11-30 21:57 ` sashiko-bot
2026-11-30 21:34 ` [PATCH v8 9/9] ASoC: qcom: lpass: " Mohammad Rafi Shaik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-242041@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mohammad.rafi.shaik@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox