From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 5/9] ASoC: amd: renoir: Use devm_pm_runtime_enable()
Date: Fri, 04 Dec 2026 11:45:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-249715@kernel.org> (raw)
In-Reply-To: <20261204111644.63432-6-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: amd: renoir: substream UAF in pdm_irq_handler() on
removal
--
commit eccba3fd34658e843b5de01f724905ffd27bc16d
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: amd: renoir: Use devm_pm_runtime_enable()
This commit switches acp_pdm_audio_probe() to devm_pm_runtime_enable(),
moves runtime PM and IRQ setup before registering the ASoC component,
and removes the remove callback.
> diff --git a/sound/soc/amd/renoir/acp3x-pdm-dma.c b/sound/soc/amd/renoir/acp3x-pdm-dma.c
> index bea1208f1702a..84ee9b9318581 100644
> --- a/sound/soc/amd/renoir/acp3x-pdm-dma.c
> +++ b/sound/soc/amd/renoir/acp3x-pdm-dma.c
> @@ -422,6 +422,22 @@ static int acp_pdm_audio_probe(struct platform_device *pdev)
> adata->capture_stream = NULL;
>
> dev_set_drvdata(&pdev->dev, adata);
> +
> + pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_mark_last_busy(&pdev->dev);
> + pm_runtime_set_active(&pdev->dev);
> + status = devm_pm_runtime_enable(&pdev->dev);
> + if (status)
> + return status;
> +
> + status = devm_request_irq(&pdev->dev, adata->pdm_irq, pdm_irq_handler,
> + irqflags, "ACP_PDM_IRQ", adata);
> + if (status) {
> + dev_err(&pdev->dev, "ACP PDM IRQ request failed\n");
> + return -ENODEV;
> + }
> +
> status = devm_snd_soc_register_component(&pdev->dev,
> &acp_pdm_component,
> &acp_pdm_dai_driver, 1);
[Severity: Medium]
Can moving devm_request_irq() before devm_snd_soc_register_component()
cause a use-after-free of capture_stream in pdm_irq_handler() on device
removal?
Because devres actions run in LIFO order, devm_component_release() now
runs before devm_irq_release(). Unregistering the component tears down
the ALSA card and frees the PCM substreams via snd_card_free() ->
snd_pcm_free_stream() while pdm_irq_handler() is still active.
Neither snd_pcm_dev_disconnect() (acp_pdm_component has no .sync_stop
callback and card->sync_irq is unset) nor acp_pdm_dma_close() calls
synchronize_irq() to wait for an in-flight handler:
CPU0 (unbind / PCI remove) CPU1 (pdm_irq_handler)
acp_pdm_dma_close()
reads capture_stream (non-NULL)
adata->capture_stream = NULL
devm_component_release()
...
snd_card_free()
snd_pcm_free_stream()
kfree(substream)
snd_pcm_period_elapsed(capture_stream)
lock(&substream->self_group.lock)
<-- use-after-free
devm_irq_release()
free_irq()
Locking the freed substream in interrupt context can corrupt memory or
oops. Keeping devm_request_irq() after devm_snd_soc_register_component()
preserves the previous teardown order so free_irq() synchronizes against
in-flight handlers before the component is unregistered.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204111644.63432-1-phucduc.bui@gmail.com?part=5
next prev parent reply other threads:[~2026-12-04 11:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:16 [PATCH v2 0/9] ASoC: amd: Use devm_pm_runtime_enable() phucduc.bui
2026-12-04 11:16 ` [PATCH v2 1/9] ASoC: amd: ps: " phucduc.bui
2026-12-04 11:16 ` [PATCH v2 2/9] ASoC: amd: ps: Simplify component registration phucduc.bui
2026-12-04 11:16 ` [PATCH v2 3/9] ASoC: amd: raven: Use devm_pm_runtime_enable() phucduc.bui
2026-12-04 11:38 ` sashiko-bot
2026-12-04 11:52 ` Mukunda,Vijendar
2026-12-04 11:16 ` [PATCH v2 4/9] ASoC: amd: raven: Preserve probe error codes phucduc.bui
2026-12-04 11:16 ` [PATCH v2 5/9] ASoC: amd: renoir: Use devm_pm_runtime_enable() phucduc.bui
2026-12-04 11:45 ` sashiko-bot [this message]
2026-12-04 11:16 ` [PATCH v2 6/9] ASoC: amd: renoir: Preserve probe error codes phucduc.bui
2026-12-04 11:16 ` [PATCH v2 7/9] ASoC: amd: vangogh: Use devm_pm_runtime_enable() phucduc.bui
2026-12-04 11:52 ` sashiko-bot
2026-12-04 11:16 ` [PATCH v2 8/9] ASoC: amd: yc: " phucduc.bui
2026-12-04 11:16 ` [PATCH v2 9/9] ASoC: amd: yc: Simplify component registration phucduc.bui
2026-12-04 12:46 ` [PATCH v2 0/9] ASoC: amd: Use devm_pm_runtime_enable() Syed Saba Kareem
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-249715@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox