From: sashiko-bot@kernel.org
To: "Valerio Setti" <vsetti@baylibre.com>
Cc: linux-amlogic@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH 1/4] ASoC: meson: gx: add gx-formatter and gx-interface
Date: Fri, 15 May 2026 15:36:51 +0000 [thread overview]
Message-ID: <20260515153651.965F8C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260515-reshape-aiu-as-axg-v1-1-53b457784ff3@baylibre.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Unhandled error paths during widget power-up leave the formatter in an incomplete state, causing deterministic kernel panics during power-down.
- [High] Missing rollback of enabled formatters in `gx_stream_start` failure path leads to hardware state leaks.
--
commit 37f14cf52933f802dadd48fb50c3876ad1e0e2c5
Author: Valerio Setti <vsetti@baylibre.com>
Subject: ASoC: meson: gx: add gx-formatter and gx-interface
This commit adds basic formatter and interface blocks to shape I2S in GX
devices. It introduces gx_formatter_create() to allow existing AIU code to
utilize the formatter without devicetree modifications.
> diff --git a/sound/soc/meson/gx-formatter.c b/sound/soc/meson/gx-formatter.c
> new file mode 100644
> index 0000000000000..db93546ed9217
> --- /dev/null
> +++ b/sound/soc/meson/gx-formatter.c
[ ... ]
> +static int gx_formatter_power_up(struct gx_formatter *formatter,
> + struct snd_soc_dapm_widget *w)
> +{
> + struct gx_stream *ts = formatter->drv->ops->get_stream(w);
> + int ret;
> +
> + /*
> + * If we don't get a stream at this stage, it would mean that the
> + * widget is powering up but is not attached to any backend DAI.
> + * It should not happen, ever !
> + */
> + if (WARN_ON(!ts))
> + return -ENODEV;
Will this cause a NULL pointer dereference later if the warning triggers?
Since ASoC DAPM core ignores error codes returned by widget PRE_PMU events,
the widget will still be considered powered up and the PRE_PMD event will
eventually execute when the stream stops.
If this returns -ENODEV here, formatter->stream remains NULL. When PRE_PMD
triggers gx_formatter_power_down() and then gx_formatter_detach(), the
detach function will attempt to lock ts->lock where ts is NULL.
> +
> + formatter->stream = ts;
> + ret = gx_formatter_attach(formatter);
> + if (ret)
> + return ret;
Could this error path also lead to a crash during the PRE_PMD teardown?
If gx_formatter_attach() fails, it skips adding formatter->list to the
stream's formatter_list. Later, when the stream stops and PRE_PMD is invoked,
gx_formatter_detach() unconditionally calls list_del(&formatter->list).
Since the list was never initialized with INIT_LIST_HEAD() or added to the
list, calling list_del() on it will dereference uninitialized pointers.
> +
> + return 0;
> +}
[ ... ]
> +int gx_stream_start(struct gx_stream *ts)
> +{
> + struct gx_formatter *formatter;
> + int ret = 0;
> +
> + mutex_lock(&ts->lock);
> +
> + /* Start all the formatters attached to the stream */
> + list_for_each_entry(formatter, &ts->formatter_list, list) {
> + ret = gx_formatter_enable(formatter);
> + if (ret) {
> + pr_err("failed to start tdm stream\n");
> + goto out;
Do we need to disable the formatters that were already successfully enabled
in previous iterations of this loop before returning?
The ALSA core does not automatically invoke the STOP trigger when a START
trigger fails. Returning an error here without rolling back the earlier
formatters could leave the hardware clocks and registers permanently enabled,
resulting in leaked resources.
> + }
> + }
> +
> + ts->ready = true;
> +
> +out:
> + mutex_unlock(&ts->lock);
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-reshape-aiu-as-axg-v1-0-53b457784ff3@baylibre.com?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-05-15 15:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 15:10 [PATCH 0/4] ASoC: meson: aiu: align I2S design to the AXG one Valerio Setti
2026-05-15 15:10 ` Valerio Setti
2026-05-15 15:10 ` [PATCH 1/4] ASoC: meson: gx: add gx-formatter and gx-interface Valerio Setti
2026-05-15 15:10 ` Valerio Setti
2026-05-15 15:36 ` sashiko-bot [this message]
2026-05-15 15:10 ` [PATCH 2/4] ASoC: meson: aiu-encoder-i2s: use gx_iface and gx_stream structures Valerio Setti
2026-05-15 15:10 ` Valerio Setti
2026-05-15 16:10 ` sashiko-bot
2026-05-15 15:10 ` [PATCH 3/4] ASoC: meson: aiu: introduce I2S output formatter Valerio Setti
2026-05-15 15:10 ` Valerio Setti
2026-05-15 15:10 ` [PATCH 4/4] ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data Valerio Setti
2026-05-15 15:10 ` Valerio Setti
2026-05-15 17:40 ` 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=20260515153651.965F8C2BCB7@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 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.