From: sashiko-bot@kernel.org
To: "Arina Kharlamova" <arina.kharlamova@mbzuai.ac.ae>
Cc: linux-sound@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] ASoC: imx-pcm-rpmsg: Destroy the workqueue after the component is gone
Date: Sun, 29 Nov 2026 07:37:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-239393@kernel.org> (raw)
In-Reply-To: <20261129-s2p-d102-v1-1-3e8ad20db1b9@mbzuai.ac.ae>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ASoC: fsl_rpmsg: non-sync timer_delete() in
imx_rpmsg_pcm_close() [1]
--
commit d5d77f25c6ce2edfdba6c5018de29919ea8a86b3
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
ASoC: imx-pcm-rpmsg: Destroy the workqueue after the component is gone
This commit switches the rpmsg workqueue allocation in imx_rpmsg_pcm_probe()
to devm_alloc_ordered_workqueue() so that devres destroys the workqueue
after unregistering the ASoC component, and removes the manual cleanup in
imx_rpmsg_pcm_remove() and the probe error path.
> diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
> index 6852f49a18adc..266ce3b3d3335 100644
> --- a/sound/soc/fsl/imx-pcm-rpmsg.c
> +++ b/sound/soc/fsl/imx-pcm-rpmsg.c
> @@ -696,7 +696,7 @@ static void imx_rpmsg_pcm_work(struct work_struct *work)
> static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
> {
> struct rpmsg_info *info;
> - int ret, i;
> + int i;
>
> info = devm_kzalloc_obj(&pdev->dev, *info);
> if (!info)
> @@ -707,10 +707,11 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
> info->rpdev = container_of(pdev->dev.parent, struct rpmsg_device, dev);
> info->dev = &pdev->dev;
> /* Setup work queue */
> - info->rpmsg_wq = alloc_ordered_workqueue(info->rpdev->id.name,
> - WQ_HIGHPRI |
> - WQ_UNBOUND |
> - WQ_FREEZABLE);
> + info->rpmsg_wq = devm_alloc_ordered_workqueue(&pdev->dev,
> + info->rpdev->id.name,
> + WQ_HIGHPRI |
> + WQ_UNBOUND |
> + WQ_FREEZABLE);
[Severity: Critical]
This problem wasn't introduced by this patch, but can
imx_rpmsg_timer_callback() race with stream teardown in
imx_rpmsg_pcm_close() [1] and queue work onto info->rpmsg_wq after
the workqueue has been flushed?
sound/soc/fsl/imx-pcm-rpmsg.c:imx_rpmsg_pcm_close() {
...
info->send_message(msg, info);
timer_delete(&info->stream_timer[substream->stream].timer);
...
}
Because timer_delete() does not wait for a concurrently running timer
callback to finish, imx_rpmsg_timer_callback() on another CPU can enqueue
new PERIOD_DONE work via imx_rpmsg_insert_workqueue() after
flush_workqueue(info->rpmsg_wq) and after the TX_CLOSE or RX_CLOSE command
has been sent:
CPU0 CPU1
imx_rpmsg_pcm_hw_free()
flush_workqueue(info->rpmsg_wq)
imx_rpmsg_timer_callback()
imx_rpmsg_insert_workqueue()
imx_rpmsg_pcm_close()
info->send_message(msg, info)
timer_delete(...)
If the queued work runs after the stream resources or workqueue are torn
down, this causes a use-after-free. Using timer_delete_sync() before
flushing the workqueue and sending the close message would prevent this
race.
[1] https://sashiko.dev/#/bug/linux-df8136ab-43bf-42a8-9969-f817dabe9dcb
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129-s2p-d102-v1-1-3e8ad20db1b9@mbzuai.ac.ae?part=1
prev parent reply other threads:[~2026-11-29 7:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 7:31 [PATCH] ASoC: imx-pcm-rpmsg: Destroy the workqueue after the component is gone Arina Kharlamova via B4 Relay
2026-11-29 7:37 ` sashiko-bot [this message]
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-239393@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=arina.kharlamova@mbzuai.ac.ae \
--cc=imx@lists.linux.dev \
--cc=linux-sound@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox