git: 648ac179d28f - stable/15 - bcm2835_sdhci: Clean up DMA resources on attach failure

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 11 Jun 2026 16:58:41 UTC
The branch stable/15 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=648ac179d28f5c15d8d84b7bb369008a3661fa6f

commit 648ac179d28f5c15d8d84b7bb369008a3661fa6f
Author:     Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
AuthorDate: 2026-05-27 02:42:43 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-06-11 16:39:31 +0000

    bcm2835_sdhci: Clean up DMA resources on attach failure
    
    bcm_sdhci_attach() allocates a DMA channel with bcm_dma_allocate()
    before creating the bus_dma tag and map.  If a later initialization
    step fails, the common error path releases the interrupt and memory
    resources, but leaves the DMA channel allocated.
    
    Call bcm_dma_free() for cleanup, as it already performs the required
    internal checks and can therefore be invoked directly.
    
    Signed-off-by:  Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
    Reviewed by:    mhorne
    MFC after:      3 days
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2241
    
    (cherry picked from commit d1488cd762bee79240a715bf04f3d30e9a121b26)
---
 sys/arm/broadcom/bcm2835/bcm2835_sdhci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
index e0c4327d8e05..6e974a1a61bb 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
@@ -365,6 +365,7 @@ bcm_sdhci_attach(device_t dev)
 	return (0);
 
 fail:
+	bcm_dma_free(sc->sc_dma_ch);
 	if (sc->sc_intrhand)
 		bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
 	if (sc->sc_irq_res)