From: "Mukunda,Vijendar" <vijendar.mukunda@amd.com>
To: Fan Wu <fanwu01@zju.edu.cn>, lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, Syed.SabaKareem@amd.com,
stable@vger.kernel.org, Song Li <songl@zju.edu.cn>,
"Dommati, Sunil-kumar" <Sunil-kumar.Dommati@amd.com>,
Syed Saba Kareem <syed.sabakareem@amd.com>,
"Prasad, Prasad" <venkataprasad.potturu@amd.com>
Subject: Re: [PATCH] ASoC: amd: ps: fix snd_acp63_remove() teardown ordering
Date: Fri, 25 Sep 2026 13:35:59 +0530 [thread overview]
Message-ID: <611b8e7a-b434-40c0-8f0e-4978208bb01f@amd.com> (raw)
In-Reply-To: <20260923092640.502145-1-fanwu01@zju.edu.cn>
On 9/23/26 14:56, Fan Wu wrote:
> The ACP threaded interrupt handler dereferences the SoundWire and PDM
> child platform devices, but snd_acp63_remove() unregisters them while
> the interrupt is still registered: devm_request_threaded_irq() ties its
> release to devres cleanup, which runs only after the remove callback
> returns. A completion in this window is a use-after-free.
>
> Fix this by masking the ACP interrupt sources and calling devm_free_irq()
> before the first child device is unregistered. The interrupt line is
> shared, and acp_hw_deinit() clears the sources only after the children
> are gone, which would leave the line raised with no handler left to
> ack it. The window predates the tagged refactor, which only reshaped
> the dereferences.
>
> This issue was found by an in-house static analysis tool.
>
> Fixes: eaf825037d6d ("ASoC: amd: ps: refactor acp child platform device creation code")
> Cc: stable@vger.kernel.org
> Co-developed-by: Song Li <songl@zju.edu.cn>
> Signed-off-by: Song Li <songl@zju.edu.cn>
> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
> ---
> sound/soc/amd/ps/pci-ps.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c
> index 729f9aa..01ee697 100644
> --- a/sound/soc/amd/ps/pci-ps.c
> +++ b/sound/soc/amd/ps/pci-ps.c
> @@ -738,6 +738,12 @@ static void snd_acp63_remove(struct pci_dev *pci)
> int ret;
>
> adata = pci_get_drvdata(pci);
> + /* Mask the interrupt sources before freeing the shared IRQ. */
> + writel(ACP_EXT_INTR_STAT_CLEAR_MASK,
> + adata->acp63_base + ACP_EXTERNAL_INTR_STAT);
> + writel(0, adata->acp63_base + ACP_EXTERNAL_INTR_CNTL);
> + writel(0, adata->acp63_base + ACP_EXTERNAL_INTR_ENB);
++ The fix open-codes the register offsets (ACP_EXTERNAL_INTR_STAT,
ACP_EXTERNAL_INTR_CNTL, ACP_EXTERNAL_INTR_ENB) directly in
snd_acp63_remove(). Future platforms may have different interrupt
control register offsets, which would require changes in this remove
path as well. Consider adding a disable_interrupts callback to struct
acp_hw_ops and invoking it here instead. This keeps the remove path
platform-agnostic and the interrupt masking logic co-located with its
platform-specific counterpart in ps-common.c.
> + devm_free_irq(&pci->dev, pci->irq, adata);
> if (adata->sdw) {
> amd_sdw_exit(adata);
> platform_device_unregister(adata->sdw_dma_dev);
prev parent reply other threads:[~2026-09-25 8:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 9:26 Fan Wu
2026-09-25 8:05 ` Mukunda,Vijendar [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=611b8e7a-b434-40c0-8f0e-4978208bb01f@amd.com \
--to=vijendar.mukunda@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=Syed.SabaKareem@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=fanwu01@zju.edu.cn \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=songl@zju.edu.cn \
--cc=stable@vger.kernel.org \
--cc=venkataprasad.potturu@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®