From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC 13/23] ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs
Date: Fri, 13 Nov 2026 19:04:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-213497@kernel.org> (raw)
In-Reply-To: <20261113-topic-sm8650-el2-v1-13-5183f6aab9fc@linaro.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: qcom: lpass: NULL deref in lpass_cpu_daiops_probe() on
unprobed LPAIF
--
commit 4c412765d7dfc4828c0e1ec1c2ada16e697ee595
Author: Neil Armstrong <neil.armstrong@linaro.org>
ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs
This commit adds an optional lpaif_mi2s_desc descriptor to struct
lpass_variant so MI2S ports can be mapped to and probed across multiple
LPAIF instances.
> diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
> index f8b9b2ec90553..411eecd9cbb93 100644
> --- a/sound/soc/qcom/lpass-cpu.c
> +++ b/sound/soc/qcom/lpass-cpu.c
> @@ -1079,6 +1079,8 @@ static void of_lpass_cpu_parse_dai_data(struct device *dev,
> data->mi2s_capture_sd_mode[port_id] =
> of_lpass_cpu_parse_sd_lines(dev, node,
> "qcom,capture-sd-lines");
> +
> + set_bit(port_id, &data->lpaif_port_enable);
> } else {
> dev_err(dev, "invalid dai id: %d\n", id);
> continue;
> @@ -1121,12 +1123,33 @@ static int lpass_cpu_init_lpaif(struct platform_device *pdev, int idx,
> struct regmap_config cfg = lpass_cpu_regmap_config;
> struct device *dev = &pdev->dev;
> void __iomem *base;
> - int ret;
> + int ret, i;
> +
> + /* Only probe an LPAIF if one of the port is described in DT */
> + if (v->mi2s_desc) {
> + const struct lpaif_mi2s_desc *desc = &v->mi2s_desc[idx];
> + bool enabled = false;
> +
> + for (i = 0; i < desc->port_desc_count; ++i) {
> + unsigned int port_id = mi2s_port_id(desc->port_desc[i].id);
> +
> + if (test_bit(port_id, &drvdata->lpaif_port_enable)) {
> + enabled = true;
> + break;
> + }
> + }
> +
> + if (!enabled)
> + return 0;
> + }
[ ... ]
> @@ -1283,8 +1320,30 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
>
> port_id = mi2s_port_id(variant->dai_driver[i].id);
>
> - drvdata->mi2s_lpaif[port_id] = &drvdata->lpaif[0];
> - drvdata->mi2s_intf[port_id] = port_id;
> + if (variant->mi2s_desc) {
> + unsigned int lpaif_idx, lpaif_port;
> + const struct lpaif_mi2s_desc *desc;
> +
> + for (lpaif_idx = 0; lpaif_idx < variant->num_mi2s_desc; ++lpaif_idx) {
> + desc = &variant->mi2s_desc[lpaif_idx];
> +
> + for (lpaif_port = 0;
> + lpaif_port < desc->port_desc_count;
> + ++lpaif_port) {
> + if (desc->port_desc[lpaif_port].id !=
> + variant->dai_driver[i].id)
> + continue;
> +
> + drvdata->mi2s_lpaif[port_id] =
> + &drvdata->lpaif[lpaif_idx];
> + drvdata->mi2s_intf[port_id] =
> + desc->port_desc[lpaif_port].intf;
> + }
> + }
> + } else {
> + drvdata->mi2s_lpaif[port_id] = &drvdata->lpaif[0];
> + drvdata->mi2s_intf[port_id] = port_id;
> + }
[Severity: Medium]
Can this cause a NULL pointer dereference in lpass_cpu_daiops_probe() when
a sound card links to an MI2S DAI whose LPAIF was skipped by
lpass_cpu_init_lpaif()?
of_lpass_cpu_parse_dai_data() only sets lpaif_port_enable for MI2S ports
that have an explicit child node under the lpass-cpu DT node, while
leaving child nodes optional when using the default 8-channel SD line
configuration. When lpass_cpu_init_lpaif() returns 0 early because
lpaif_port_enable is not set for any port on that LPAIF, lpaif->drvdata,
lpaif->map and lpaif->i2sctl remain NULL, and lpass_platform_init_lpaif()
likewise skips initializing lpaif->rd_dmactl and lpaif->wr_dmactl.
However, asoc_qcom_lpass_cpu_platform_probe() still points
drvdata->mi2s_lpaif[port_id] at &drvdata->lpaif[lpaif_idx] (or leaves it
NULL if the DAI is not listed in variant->mi2s_desc) and registers all
variant->dai_driver DAIs. Unlike the platform suspend/resume paths,
lpass_cpu_daiops_probe() and lpass_platform_pcmops_open() do not check
whether the LPAIF was initialized before dereferencing lpaif and passing
lpaif->map to regmap_write():
sound/soc/qcom/lpass-cpu.c:lpass_cpu_daiops_probe() {
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
unsigned int port_id = mi2s_port_id(dai->driver->id);
struct lpass_lpaif *lpaif = drvdata->mi2s_lpaif[port_id];
int ret;
/* ensure audio hardware is disabled */
ret = regmap_write(lpaif->map,
LPAIF_I2SCTL_REG(drvdata->variant, drvdata->mi2s_intf[port_id]), 0);
...
}
Checking !lpaif || !lpaif->drvdata in lpass_cpu_daiops_probe() and
returning -ENODEV would prevent probing an uninitialized LPAIF.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-topic-sm8650-el2-v1-0-5183f6aab9fc@linaro.org?part=13
next prev parent reply other threads:[~2026-11-13 19:04 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 18:38 [PATCH RFC 00/23] arm64: qcom: enable SM8650 audio without ADSP firmware Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 01/23] dt-bindings: clock: qcom: add SM8650 LPASS core & audio clock controllers Neil Armstrong
2026-11-13 18:57 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 02/23] clk: " Neil Armstrong
2026-11-13 19:14 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 03/23] dt-bindings: pinctrl: qcom,sm8650-lpass-lpi-pinctrl: document clocks and power domaines when ADSP is not used Neil Armstrong
2026-11-13 19:02 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 04/23] ASoC: dt-bindings: qcom,lpass: add Senary & Septenary MI2S ids Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 05/23] ASoC: dt-bindings: qcom,lpass: add WSA RX and TX channels ids Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 06/23] ASoC: dt-bindings: qcom,lpass-*-macro: document less clock when ADSP is not used Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 07/23] ASoC: dt-bindings: qcom,lpass-cpu: document the SM8650 LPASS Neil Armstrong
2026-11-13 18:57 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 08/23] ASoC: qcom: lpass-cpu: get the optional codec_mem3 clock Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 09/23] ASoC: qcom: lpass: add support for optional WSA interface Neil Armstrong
2026-11-13 19:11 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 10/23] ASoC: qcom: lpass-cdc-dma: add support for WSA codec DMA Neil Armstrong
2026-11-13 19:07 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 11/23] ASoC: qcom: lpass: prepare to handle multiple lpaifs for i2s Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 12/23] ASoC: qcom: lpass: add support for MI2S_SENARY & MI2S_SEPTENARY Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 13/23] ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs Neil Armstrong
2026-11-13 19:04 ` sashiko-bot [this message]
2026-11-13 18:38 ` [PATCH RFC 14/23] ASoC: qcom: lpass: support LPM memory type for I2S LPAIFs Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 15/23] ASoC: qcom: lpass: allocate LPM buffer memory to DAIs Neil Armstrong
2026-11-13 19:12 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 16/23] ASoC: qcom: lpass: enable the right codec_mem clock when usin LPM memory Neil Armstrong
2026-11-13 19:06 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 17/23] ASoC: qcom: add SM8650 LPASS CPU driver Neil Armstrong
2026-11-13 19:22 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 18/23] ASoC: qcom: swd: allow LPASS_CDC_DMA_WSA_RX0 as soundwire dai Neil Armstrong
2026-11-13 18:38 ` [PATCH RFC 19/23] ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu Neil Armstrong
2026-11-13 19:12 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 20/23] arm64: dts: qcom: sm8650: move EL1 Gunyah nodes to sm8650-el1.dtsi Neil Armstrong
2026-11-13 19:08 ` Val Packett
2026-11-13 19:11 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 21/23] arm64: dts: qcom: add SM8650 LPASS CPU dtsi Neil Armstrong
2026-11-13 19:18 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 22/23] arm64: dts: qcom: sm8650-valve-deckard: enable audio Neil Armstrong
2026-11-13 19:23 ` sashiko-bot
2026-11-13 18:38 ` [PATCH RFC 23/23] arm64: defconfig: enable the SM8650 LPASS CPU driver Neil Armstrong
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-213497@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--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 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.