From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 16/24] ASoC: qcom: audioreach: add speaker protection mixer controls
Date: Fri, 04 Dec 2026 14:01:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-249920@kernel.org> (raw)
In-Reply-To: <20261204113101.1141644-17-srinivas.kandagatla@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] ASoC: qcom: audioreach: missing sp_cal_watchdog cancel in
apm_remove()
- [Medium] ASoC: qcom: audioreach: watchdog race in
audioreach_sp_finish_calibration()
- [Medium] ASoC: qcom: missing RO/volatile flags in
audioreach_control_load()
- [Medium] ASoC: qcom: unchecked hdr->type cast in
audioreach_control_load()
- [Medium] ASoC: qcom: unratelimited log flood via
audioreach_put_sp_r0t0()
- [Medium] ASoC: qcom: sp_op_mode enum count mismatch in
audioreach_get_sp_op_mode()
--
commit a161a89d518c1d4827e5dbf7333beb85038a9af6
Author: Ravi Hothi <ravi.hothi@oss.qualcomm.com>
ASoC: qcom: audioreach: add speaker protection mixer controls
This commit adds topology kcontrol IDs and handlers for the speaker
protection operation mode and per-speaker R0/T0 calibration values in
audioreach.
> diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c
> index 5dd7f2c51d5cf..f9a3e9cf4119e 100644
> --- a/sound/soc/qcom/qdsp6/topology.c
> +++ b/sound/soc/qcom/qdsp6/topology.c
> @@ -1465,6 +1465,68 @@ static int audioreach_put_vol_ctrl_audio_mixer(struct snd_kcontrol *kcontrol,
> return 1;
> }
>
> +static int audioreach_get_sp_op_mode(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + ucontrol->value.enumerated.item[0] = audioreach_get_sp_operation_mode();
> +
> + return 0;
> +}
[Severity: Medium]
Can snd_soc_info_enum_double() advertise a 2-channel enum while
audioreach_get_sp_op_mode() only populates item[0]?
In soc_tplg_control_denum_create(), se->shift_l and se->shift_r come from
tplg_chan_get_shift() for SNDRV_CHMAP_FL and SNDRV_CHMAP_FR. When a topology
defines only SNDRV_CHMAP_FL, se->shift_r is assigned (unsigned char)-EINVAL,
so se->shift_l != se->shift_r and snd_soc_info_enum_double() reports
uinfo->count = 2. Because item[1] is left untouched from the caller buffer,
reads echo stale caller data or fail with -EINVAL under CONFIG_SND_CTL_DEBUG
in sanity_check_elem_value().
Normalizing se->shift_r = se->shift_l in audioreach_control_load() (or using
a single-channel enum info callback) avoids the mismatch.
[Severity: High]
Does unloading snd-q6apm while sp_cal_watchdog is pending cause a
use-after-free?
audioreach_trigger_sp_calibration() schedules the module-static
sp_cal_watchdog delayed work for 60 seconds, but commit "ASoC: qcom:
audioreach: send cached R0/T0 to the VI module in normal mode" removed
audioreach_sp_shutdown() and its call from apm_remove() in
sound/soc/qcom/qdsp6/q6apm.c. If snd-q6apm is unloaded within 60 seconds of
triggering calibration, sp_cal_watchdog fires against freed module text and
data.
Calling cancel_delayed_work_sync(&sp_cal_watchdog) from apm_remove() avoids
leaving the timer active across unbind and module unload.
[Severity: Medium]
Can audioreach_sp_finish_calibration() cancel a newly started calibration's
watchdog or race with a running watchdog callback?
In sound/soc/qcom/qdsp6/audioreach.c, audioreach_sp_finish_calibration()
resets sp_operation_mode to Normal before calling non-synchronous
cancel_delayed_work(&sp_cal_watchdog):
CPU0 CPU1
audioreach_sp_finish_calibration()
WRITE_ONCE(sp_operation_mode,
NORMAL)
audioreach_trigger_sp_calibration()
cmpxchg(NORMAL -> CALIBRATION)
schedule_delayed_work(
&sp_cal_watchdog, ...)
cancel_delayed_work(
&sp_cal_watchdog) <-- cancels CPU1's watchdog
That leaves CPU1's calibration running with no timeout guard. In addition,
because cancel_delayed_work() does not wait for an in-flight
audioreach_sp_cal_watchdog_fn(), an older watchdog callback can run its
cmpxchg(CALIBRATION -> NORMAL) and prematurely abort a newly triggered
calibration.
> +/*
> + * "Speaker Protection Operation Mode" is read-only status. Enter
> + * Calibration via the "Speaker Protection Calibrate" trigger instead,
> + * so a stale alsactl state file cannot flip the DSP into Calibration
> + * and nothing can leave the system stuck there.
> + */
> +static int audioreach_put_sp_op_mode(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + return -EACCES;
> +}
[Severity: Medium]
Should audioreach_control_load() enforce read-only access on
SND_SOC_AR_TPLG_SP_OP_MODE_CTL instead of returning -EACCES from put?
When a topology omits hdr.access (0), snd_ctl_new1() defaults it to
SNDRV_CTL_ELEM_ACCESS_READWRITE, so alsactl saves and tries to restore the
control and fails with -EACCES (and ALSA read-only controls are expected to
reject writes with -EPERM in snd_ctl_elem_write()). Stripping
SNDRV_CTL_ELEM_ACCESS_WRITE, setting SNDRV_CTL_ELEM_ACCESS_READ |
SNDRV_CTL_ELEM_ACCESS_VOLATILE, and clearing kc->put = NULL in
audioreach_control_load() gives standard read-only semantics.
Because both sp_operation_mode and sp_vi_r0t0_cfg change asynchronously from
DSP events and timers without snd_ctl_notify(), SND_SOC_AR_TPLG_SP_R0T0_CTL
should also set SNDRV_CTL_ELEM_ACCESS_VOLATILE.
[ ... ]
> +static int audioreach_put_sp_r0t0(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_component *scomp = snd_kcontrol_chip(kcontrol);
> + long cur[AR_SP_R0T0_CTL_COUNT];
> + int ret;
> +
> + audioreach_get_sp_vi_r0t0(cur, AR_SP_R0T0_CTL_COUNT);
> + if (!memcmp(cur, ucontrol->value.integer.value, sizeof(cur)))
> + return 0;
> +
> + ret = audioreach_set_sp_vi_r0t0(scomp->dev, ucontrol->value.integer.value,
> + AR_SP_R0T0_CTL_COUNT);
> + if (ret < 0)
> + return ret;
> +
> + return 1;
> +}
[Severity: Medium]
Can userspace flood the kernel log through audioreach_put_sp_r0t0()?
audioreach_set_sp_vi_r0t0() emits unratelimited dev_err() messages on invalid
values and up to MAX_SP_VI_SPEAKERS unratelimited dev_info() lines on each
valid change, so any user with access to /dev/snd/controlC* can flood dmesg
at ioctl speed by repeating out-of-range writes or alternating two valid
R0/T0 sets. Using dev_err_ratelimited() and dev_dbg() in
audioreach_set_sp_vi_r0t0() avoids unbounded kernel logging.
[ ... ]
> @@ -1524,6 +1587,14 @@ static int audioreach_control_load(struct snd_soc_component *scomp, int index,
> sm = (struct soc_mixer_control *)kc->private_value;
> dobj = &sm->dobj;
> break;
> + case SND_SOC_AR_TPLG_SP_R0T0_CTL:
> + sm = (struct soc_mixer_control *)kc->private_value;
> + dobj = &sm->dobj;
> + break;
> + case SND_SOC_AR_TPLG_SP_OP_MODE_CTL:
> + se = (struct soc_enum *)kc->private_value;
> + dobj = &se->dobj;
> + break;
> default:
> dev_warn(scomp->dev, "control type not supported %d:%d:%d\n",
> hdr->ops.get, hdr->ops.put, hdr->ops.info);
> @@ -1550,6 +1621,10 @@ static const struct snd_soc_tplg_kcontrol_ops audioreach_io_ops[] = {
> audioreach_put_audio_mixer, snd_soc_info_volsw},
> {SND_SOC_AR_TPLG_VOL_CTL, audioreach_get_vol_ctrl_audio_mixer,
> audioreach_put_vol_ctrl_audio_mixer, snd_soc_info_volsw},
> + {SND_SOC_AR_TPLG_SP_OP_MODE_CTL, audioreach_get_sp_op_mode,
> + audioreach_put_sp_op_mode, snd_soc_info_enum_double},
> + {SND_SOC_AR_TPLG_SP_R0T0_CTL, audioreach_get_sp_r0t0,
> + audioreach_put_sp_r0t0, audioreach_info_sp_r0t0},
> };
[Severity: Medium]
Can a mismatched hdr->type cause type confusion and an out-of-bounds write in
audioreach_control_load()?
soc_tplg_kcontrol_elems_load() allocates kc->private_value according to
control_hdr->type, whereas audioreach_control_load() casts kc->private_value
to struct soc_mixer_control or struct soc_enum based only on hdr->ops.get.
If a topology pairs SND_SOC_AR_TPLG_SP_R0T0_CTL or
SND_SOC_AR_TPLG_SP_OP_MODE_CTL with SND_SOC_TPLG_TYPE_BYTES, writing
dobj->private = scontrol writes 8 bytes past the end of the smaller struct
soc_bytes_ext allocation and leaks scontrol on unload.
In addition, pairing SND_SOC_AR_TPLG_SP_OP_MODE_CTL with
SND_SOC_TPLG_TYPE_MIXER lets soc_tplg_kcontrol_bind_io() bind
snd_soc_info_enum_double() onto a struct soc_mixer_control (dereferencing
mixer fields as e->texts), while legitimate SND_SOC_TPLG_TYPE_ENUM controls
cannot use vendor ops.info ID 258 because soc_tplg_control_denum_create()
rejects non-standard enum info IDs first. Checking le32_to_cpu(hdr->type)
against SND_SOC_TPLG_TYPE_MIXER or SND_SOC_TPLG_TYPE_ENUM before casting
prevents this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204113101.1141644-1-srinivas.kandagatla@oss.qualcomm.com?part=16
next prev parent reply other threads:[~2026-12-04 14:01 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:30 [PATCH v5 00/24] ASoC: qcom: AudioReach Active speaker protection for WSA88xx Srinivas Kandagatla
2026-12-04 11:30 ` [PATCH v5 01/24] ASoC: soc-core: bump MAX_DEFAULT_CH_MAP_SIZE to 18 Srinivas Kandagatla
2026-12-04 11:30 ` [PATCH v5 02/24] ASoC: soc-pcm: add multi_direction_codecs link flag Srinivas Kandagatla
2026-12-04 12:01 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 03/24] ASoC: soc-dai: export snd_soc_dai_stream_valid Srinivas Kandagatla
2026-12-04 11:30 ` [PATCH v5 04/24] ASoC: qcom: sdw: add per-direction stream runtimes for multi_direction links Srinivas Kandagatla
2026-12-04 12:12 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 05/24] ASoC: dt-bindings: qcom,wsa8840: allow one sound DAI cell Srinivas Kandagatla
2026-12-04 11:30 ` [PATCH v5 06/24] ASoC: codecs: wsa884x: add VI sense capture DAI Srinivas Kandagatla
2026-12-04 12:38 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 07/24] ASoC: codecs: wsa883x: " Srinivas Kandagatla
2026-12-04 12:33 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 08/24] ASoC: codecs: wsa884x: register the die temperature as a thermal zone Srinivas Kandagatla
2026-12-04 13:34 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 09/24] ASoC: qcom: audioreach: add control link support to graphs Srinivas Kandagatla
2026-12-04 13:35 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 10/24] ASoC: qcom: audioreach: run VI module in calibration mode with per-speaker events Srinivas Kandagatla
2026-12-04 13:32 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 11/24] ASoC: qcom: q6apm-dai: add S32_LE format support Srinivas Kandagatla
2026-12-04 11:30 ` [PATCH v5 12/24] ASoC: qcom: audioreach: cache VI calibration results per speaker Srinivas Kandagatla
2026-12-04 13:32 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 13/24] ASoC: qcom: audioreach: add speaker protection calibration trigger infrastructure Srinivas Kandagatla
2026-12-04 13:25 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 14/24] ASoC: qcom: audioreach: send cached R0/T0 to the VI module in normal mode Srinivas Kandagatla
2026-12-04 13:43 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 15/24] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules Srinivas Kandagatla
2026-12-04 13:50 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 16/24] ASoC: qcom: audioreach: add speaker protection mixer controls Srinivas Kandagatla
2026-12-04 14:01 ` sashiko-bot [this message]
2026-12-04 11:30 ` [PATCH v5 17/24] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Srinivas Kandagatla
2026-12-04 13:56 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 18/24] ASoC: qcom: audioreach: add live speaker temperature (T0) readback Srinivas Kandagatla
2026-12-04 14:04 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 19/24] ASoC: qcom: audioreach: add speaker protection calibration state control Srinivas Kandagatla
2026-12-04 13:59 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 20/24] ASoC: qcom: x1e80100: carry WSA VI feedback on the WSA Playback BE link Srinivas Kandagatla
2026-12-04 14:11 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 21/24] ASoC: qcom: x1e80100: register WSA speaker thermal zones for speaker protection Srinivas Kandagatla
2026-12-04 14:16 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 22/24] arm64: dts: qcom: glymur-crd: add WSA speaker protection VI feedback Srinivas Kandagatla
2026-12-04 14:18 ` sashiko-bot
2026-12-04 11:30 ` [PATCH v5 23/24] arm64: dts: qcom: mahua-t14s: " Srinivas Kandagatla
2026-12-04 14:16 ` sashiko-bot
2026-12-04 11:31 ` [PATCH v5 24/24] arm64: dts: qcom: x1e78100-t14s: " Srinivas Kandagatla
2026-12-04 14:24 ` sashiko-bot
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-249920@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=srinivas.kandagatla@oss.qualcomm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.