Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: mixart: Don't touch the mailbox when the BAR mapping failed
@ 2026-11-24  4:47 Suyuan Wang via B4 Relay
  2026-11-24 12:46 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-24  4:47 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-sound, linux-kernel

From: Suyuan Wang <stevewong@hust.edu.cn>

snd_mixart_probe() calls snd_mixart_free() when pci_ioremap_bar() fails
for either BAR. snd_mixart_free() then unconditionally calls

	snd_mixart_exit_mailbox(mgr);

which masks the outbound mailbox interrupts by writing to
MIXART_REG(mgr, MIXART_PCI_OMIMR_OFFSET), i.e. through mgr->mem[1].virt.
mem[1].virt is still NULL if either BAR mapping fails, so the error
path oopses on a write near address 0 instead of returning -EBUSY.

Only call snd_mixart_exit_mailbox() when the register BAR is mapped. The
rest of snd_mixart_free() already copes with a partly set up manager:
iounmap() accepts NULL, and the IRQ and DMA buffers are checked before
release.

Found with a static analysis tool and checked by hand.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
Compile tested on x86_64 (W=1, no new warnings). I don't have a miXart board.
---
 sound/pci/mixart/mixart.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index f451554cff5f..0266467734ca 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1066,8 +1066,9 @@ static int snd_mixart_free(struct mixart_mgr *mgr)
 			snd_card_free(mgr->chip[i]->card);
 	}
 
-	/* stop mailbox */
-	snd_mixart_exit_mailbox(mgr);
+	/* stop mailbox, unless the register BAR was never mapped */
+	if (mgr->mem[1].virt)
+		snd_mixart_exit_mailbox(mgr);
 
 	/* release irq  */
 	if (mgr->irq >= 0)





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  4:47 [PATCH] ALSA: mixart: Don't touch the mailbox when the BAR mapping failed Suyuan Wang via B4 Relay
2026-11-24 12:46 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox