[PATCH v3 1/5] ASoC: amd: yc: stop the shared IRQ before tearing down platform devices
From: MuXian Chen
Date: Thu Dec 03 2026 - 07:15:00 EST
The IRQ handler dereferences adata->pdev[0], which is freed by
platform_device_unregister(). The IRQ is released only afterwards via
devres, so a spurious interrupt in that window dereferences freed
memory:
BUG: kernel NULL pointer dereference, address: 0x10
RIP: acp6x_irq_handler
Disable the interrupts and release the IRQ before unregistering the
platform devices, and return IRQ_NONE if the drvdata has already been
cleared.
Signed-off-by: MuXian Chen <a18165943161@xxxxxxxxx>
---
sound/soc/amd/yc/pci-acp6x.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sound/soc/amd/yc/pci-acp6x.c b/sound/soc/amd/yc/pci-acp6x.c
index baf2bae..a961e38 100644
--- a/sound/soc/amd/yc/pci-acp6x.c
+++ b/sound/soc/amd/yc/pci-acp6x.c
@@ -133,6 +133,8 @@ static irqreturn_t acp6x_irq_handler(int irq, void *dev_id)
val = acp6x_readl(adata->acp6x_base + ACP_EXTERNAL_INTR_STAT);
if (val & BIT(PDM_DMA_STAT)) {
yc_pdm_data = dev_get_drvdata(&adata->pdev[0]->dev);
+ if (!yc_pdm_data)
+ return IRQ_NONE;
acp6x_writel(BIT(PDM_DMA_STAT), adata->acp6x_base + ACP_EXTERNAL_INTR_STAT);
if (yc_pdm_data->capture_stream)
snd_pcm_period_elapsed(yc_pdm_data->capture_stream);
@@ -355,6 +357,13 @@ static void snd_acp6x_remove(struct pci_dev *pci)
int ret, index;
adata = pci_get_drvdata(pci);
+
+ /* Stop the shared IRQ before the platform devices it dereferences
+ * are unregistered.
+ */
+ acp6x_disable_interrupts(adata->acp6x_base);
+ devm_free_irq(&pci->dev, pci->irq, adata);
+
if (adata->acp6x_audio_mode == ACP6x_PDM_MODE) {
for (index = 0; index < ACP6x_DEVS; index++)
platform_device_unregister(adata->pdev[index]);
--
2.56.1