From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH] ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks
Date: Wed, 10 Jun 2026 10:32:09 +0000 [thread overview]
Message-ID: <20260610103210.2ACAC1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610102153.83367-1-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] If `axg_tdm_formatter_attach()` fails to enable the formatter (e.g. when trying to catch up to an already running stream), it returns an error and skips `list_add_tail()`. However, the DAPM framework will log the error but still mark the widget as powered up. Later, during teardown or routing changes, DAPM will call `axg_tdm_formatter_dettach()`, which blindly executes `list_del(&formatter->list)`. Since the list head is zero-initialized by `devm_kzalloc` and was never added to the list, `list_del()` will dereference NULL pointers, causing a kernel crash.
- [High] The return value of `axg_tdm_stream_start()` is completely ignored in `axg_tdm_iface_trigger()`. If the stream fails to start (for example, due to a failure in `axg_tdm_formatter_enable()`), `axg_tdm_stream_start()` correctly returns an error code. However, `axg_tdm_iface_trigger()` drops this error and unconditionally returns 0.
--
commit d9e23c7e7ade1061d83943c614a45fe952dec33d
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
> diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c
> --- a/sound/soc/meson/axg-tdm-formatter.c
> +++ b/sound/soc/meson/axg-tdm-formatter.c
> @@ -157,20 +157,19 @@ static int axg_tdm_formatter_attach(struct axg_tdm_formatter *formatter)
> struct axg_tdm_stream *ts = formatter->stream;
> int ret = 0;
>
> - mutex_lock(&ts->lock);
> + guard(mutex)(&ts->lock);
>
> /* Catch up if the stream is already running when we attach */
> if (ts->ready) {
> ret = axg_tdm_formatter_enable(formatter);
> if (ret) {
> pr_err("failed to enable formatter\n");
> - goto out;
> + return ret;
> }
> }
>
> list_add_tail(&formatter->list, &ts->formatter_list);
> -out:
> - mutex_unlock(&ts->lock);
> +
> return ret;
> }
[Severity: High]
This is a pre-existing issue, but if axg_tdm_formatter_enable() fails,
this error path returns early and skips list_add_tail().
If the DAPM framework logs the error but still marks the widget as powered
up, it might later call axg_tdm_formatter_dettach() during teardown or
routing changes.
Since axg_tdm_formatter_dettach() blindly executes:
scoped_guard(mutex, &ts->lock)
list_del(&formatter->list);
Does this result in a NULL pointer dereference because the list head is
zero-initialized and was never actually added to the list?
[ ... ]
> @@ -330,7 +328,7 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts)
> struct axg_tdm_formatter *formatter;
> int ret = 0;
>
> - mutex_lock(&ts->lock);
> + guard(mutex)(&ts->lock);
> ts->ready = true;
>
> /* Start all the formatters attached to the stream */
> @@ -338,12 +336,10 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts)
> ret = axg_tdm_formatter_enable(formatter);
> if (ret) {
> pr_err("failed to start tdm stream\n");
> - goto out;
> + return ret;
> }
> }
>
> -out:
> - mutex_unlock(&ts->lock);
> return ret;
> }
[Severity: High]
This isn't a bug introduced by this patch, but is it possible for the
return value of axg_tdm_stream_start() to be lost?
Looking at axg_tdm_iface_trigger() in sound/soc/meson/axg-tdm-interface.c:
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
axg_tdm_stream_start(ts);
break;
If axg_tdm_stream_start() returns an error code here, the error isn't
propagated back to ALSA. Does this mask the initialization failure and
cause the framework to silently fail, leaving applications to hang while
waiting for period elapsed events?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260610102153.83367-1-phucduc.bui@gmail.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-06-10 10:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 10:21 [PATCH] ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks phucduc.bui
2026-06-10 10:21 ` phucduc.bui
2026-06-10 10:32 ` sashiko-bot [this message]
2026-06-10 13:11 ` Jerome Brunet
2026-06-10 12:54 ` Jerome Brunet
2026-06-10 12:54 ` Jerome Brunet
2026-06-10 15:46 ` Mark Brown
2026-06-10 15:46 ` Mark Brown
2026-06-10 16:27 ` Bui Duc Phuc
2026-06-10 16:27 ` Bui Duc Phuc
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=20260610103210.2ACAC1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=phucduc.bui@gmail.com \
--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.