From: sashiko-bot@kernel.org
To: "Valerio Setti" <vsetti@baylibre.com>
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH v2 4/4] ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data
Date: Wed, 10 Jun 2026 21:39:59 +0000 [thread overview]
Message-ID: <20260610214000.7794F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610-reshape-aiu-as-axg-v2-4-cac3663a8b51@baylibre.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Mutation of a global static template array with instance-specific data breaks the device driver model and enables data races.
- [Medium] Missing cleanup of global template array on error path, causing a dangling pointer.
--
commit 0aa6e4b317dd7227cb1e1e58ed456735772485cc
Author: Valerio Setti <vsetti@baylibre.com>
ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data
Create a new DAPM widget for the "I2S formatter" and place it on the path
between the FIFO and output DAI interface. This also removes the I2S output
formatting code from aiu-encoder-i2s since it's now handled by the new
aiu-formatter-i2s widget.
> diff --git a/sound/soc/meson/aiu.c b/sound/soc/meson/aiu.c
> index f2890111c1d2c..64ace4d25d92c 100644
> --- a/sound/soc/meson/aiu.c
> +++ b/sound/soc/meson/aiu.c
> @@ -29,13 +29,22 @@ static SOC_ENUM_SINGLE_DECL(aiu_spdif_encode_sel_enum, AIU_I2S_MISC,
> static const struct snd_kcontrol_new aiu_spdif_encode_mux =
> SOC_DAPM_ENUM("SPDIF Buffer Src", aiu_spdif_encode_sel_enum);
>
> -static const struct snd_soc_dapm_widget aiu_cpu_dapm_widgets[] = {
> - SND_SOC_DAPM_MUX("SPDIF SRC SEL", SND_SOC_NOPM, 0, 0,
> - &aiu_spdif_encode_mux),
> +#define AIU_WIDGET_SPDIF_SRC_SEL 0
> +#define AIU_WIDGET_I2S_FORMATTER 1
> +
> +static struct snd_soc_dapm_widget aiu_cpu_dapm_widgets[] = {
[Severity: High]
Does removing the const qualifier here and modifying the global template array
during aiu_probe() break the device driver model?
If multiple instances of this device are probed, won't they overwrite each
other's instance pointers in this shared array, potentially causing data races
or a use-after-free?
> + [AIU_WIDGET_SPDIF_SRC_SEL] =
> + SND_SOC_DAPM_MUX("SPDIF SRC SEL", SND_SOC_NOPM, 0, 0,
> + &aiu_spdif_encode_mux),
> + [AIU_WIDGET_I2S_FORMATTER] =
> + SND_SOC_DAPM_PGA_E("I2S Formatter", SND_SOC_NOPM, 0, 0, NULL, 0,
> + gx_formatter_event,
> + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> };
[ ... ]
> @@ -282,6 +296,14 @@ static int aiu_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + /* Allocate the aiu-formatter into its widget */
> + ret = gx_formatter_create(dev, &aiu_cpu_dapm_widgets[AIU_WIDGET_I2S_FORMATTER],
> + &aiu_formatter_i2s_drv, map);
> + if (ret) {
> + dev_err(dev, "Failed to allocate aiu formatter\n");
> + goto err;
> + }
> +
> /* Register the cpu component of the aiu */
> ret = snd_soc_register_component(dev, &aiu_cpu_component,
> aiu_cpu_dai_drv,
[Severity: Medium]
If snd_soc_register_component() fails, should this path use "goto err" instead
of returning directly?
Looking at the rest of aiu_probe():
ret = snd_soc_register_component(dev, &aiu_cpu_component,
aiu_cpu_dai_drv,
ARRAY_SIZE(aiu_cpu_dai_drv));
if (ret) {
dev_err(dev, "Failed to register cpu component\n");
return ret;
}
Since gx_formatter_create() allocates memory and assigns it to the global
array, returning directly skips the gx_formatter_free() call at the err label.
The devres framework will free the memory, but wouldn't this leave a dangling
pointer in the global aiu_cpu_dapm_widgets array?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260610-reshape-aiu-as-axg-v2-0-cac3663a8b51@baylibre.com?part=4
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-06-10 21:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 21:29 [PATCH v2 0/4] ASoC: meson: aiu: align I2S design to the AXG one Valerio Setti
2026-06-10 21:29 ` [PATCH v2 1/4] ASoC: meson: gx: add gx-formatter and gx-interface Valerio Setti
2026-06-10 21:29 ` [PATCH v2 2/4] ASoC: meson: aiu-encoder-i2s: prepare for multiple streams Valerio Setti
2026-06-10 21:41 ` sashiko-bot
2026-06-11 8:16 ` Jerome Brunet
2026-06-12 13:19 ` Mark Brown
2026-06-10 21:29 ` [PATCH v2 3/4] ASoC: meson: aiu: introduce I2S output formatter Valerio Setti
2026-06-10 21:29 ` [PATCH v2 4/4] ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data Valerio Setti
2026-06-10 21:39 ` sashiko-bot [this message]
2026-06-11 8:28 ` [PATCH v2 0/4] ASoC: meson: aiu: align I2S design to the AXG one Jerome Brunet
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=20260610214000.7794F1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vsetti@baylibre.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox