From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 09/11] ASoC: fsl_rpmsg: Use guard() for mutex & spin locks
Date: Fri, 12 Jun 2026 13:42:43 +0000 [thread overview]
Message-ID: <20260612134244.738911F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612132639.78086-10-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Non-synchronous timer cancellation in teardown paths (`imx_rpmsg_pcm_close` and `imx_rpmsg_terminate_all`) can lead to use-after-free, queueing work on a destroyed workqueue, and sending messages after stream closure.
--
commit ad07813ef8b508a94e71b5247875307259ab8409
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: fsl_rpmsg: Use guard() for mutex & spin locks
This commit cleans up the code by using guard() for mutex and spin locks.
This is intended to be a refactoring with no behavior change.
> diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
> index 031e5272215d4..7210393dfa5d9 100644
> --- a/sound/soc/fsl/imx-pcm-rpmsg.c
> +++ b/sound/soc/fsl/imx-pcm-rpmsg.c
> @@ -39,10 +39,9 @@ static int imx_rpmsg_pcm_send_message(struct rpmsg_msg *msg,
> struct rpmsg_device *rpdev = info->rpdev;
> int ret = 0;
>
> - mutex_lock(&info->msg_lock);
> + guard(mutex)(&info->msg_lock);
> if (!rpdev) {
> dev_err(info->dev, "rpmsg channel not ready\n");
> - mutex_unlock(&info->msg_lock);
> return -EINVAL;
> }
>
[ ... ]
[Severity: High]
This is a pre-existing issue, but the driver uses timer_delete() instead of
timer_delete_sync() or timer_shutdown_sync() during teardown paths.
In imx_rpmsg_pcm_close():
imx_rpmsg_pcm_close() {
...
/* Flush work in workqueue to make TX_CLOSE is the last message */
flush_workqueue(info->rpmsg_wq);
...
info->send_message(msg, info);
timer_delete(&info->stream_timer[substream->stream].timer);
...
}
Because timer_delete() is called after flush_workqueue(), could a concurrently
firing timer insert a new TX_PERIOD_DONE work into the workqueue after the
workqueue is flushed and the close message has been sent?
Furthermore, during device unbind or module removal, the workqueue is
destroyed and the info struct is freed.
If the timer callback fires concurrently during teardown, would it attempt to
queue work on the destroyed workqueue and access freed memory, resulting in a
use-after-free?
A similar pattern exists in imx_rpmsg_terminate_all():
imx_rpmsg_terminate_all() {
...
timer_delete(&info->stream_timer[substream->stream].timer);
return imx_rpmsg_insert_workqueue(substream, msg, info);
}
Does this non-synchronous cancellation allow out-of-order PERIOD_DONE
messages to be sent after the terminate message?
Should timer_delete_sync() be used in these paths to ensure the callback
is completely finished before proceeding?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612132639.78086-1-phucduc.bui@gmail.com?part=9
next prev parent reply other threads:[~2026-06-12 13:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 13:26 [PATCH 00/11] ASoC: fsl: Use guard() for mutex & spin locks phucduc.bui
2026-06-12 13:26 ` [PATCH 01/11] ASoC: fsl_asrc: Use guard() for " phucduc.bui
2026-06-12 13:38 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 02/11] ASoC: fsl_audmix: " phucduc.bui
2026-06-12 13:26 ` [PATCH 03/11] ASoC: fsl_easrc: " phucduc.bui
2026-06-12 13:36 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 04/11] ASoC: fsl_esai: " phucduc.bui
2026-06-12 13:26 ` [PATCH 05/11] ASoC: fsl_spdif: " phucduc.bui
2026-06-12 13:38 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 06/11] ASoC: fsl_ssi: Use guard() for mutex locks phucduc.bui
2026-06-12 13:26 ` [PATCH 07/11] ASoC: fsl_xcvr: Use guard() for spin locks phucduc.bui
2026-06-12 13:37 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 08/11] ASoC: imx-audio-rpmsg: " phucduc.bui
2026-06-12 13:46 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 09/11] ASoC: fsl_rpmsg: Use guard() for mutex & " phucduc.bui
2026-06-12 13:42 ` sashiko-bot [this message]
2026-06-12 13:26 ` [PATCH 10/11] ASoC: fsl: mpc5200_dma: Use guard() for " phucduc.bui
2026-06-12 13:44 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 11/11] ASoC: fsl: mpc5200_psc_ac97: Use guard() for mutex locks phucduc.bui
2026-06-12 13:42 ` sashiko-bot
2026-06-12 15:05 ` Mark Brown
2026-06-12 21:42 ` 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=20260612134244.738911F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--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.