git: 30f16ad460e2 - main - dwc: Release resources when attach fails
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Feb 2022 09:02:08 UTC
The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=30f16ad460e2f9631484d04f067d80ee578473bc commit 30f16ad460e2f9631484d04f067d80ee578473bc Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-02-22 08:53:11 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2022-02-22 09:01:54 +0000 dwc: Release resources when attach fails PR: 259282 MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/dev/dwc/if_dwc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 703c210a8f87..8bc0c0e7b6c3 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -1611,6 +1611,7 @@ dwc_attach(device_t dev) /* Reset the PHY if needed */ if (dwc_reset(dev) != 0) { device_printf(dev, "Can't reset the PHY\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1626,6 +1627,7 @@ dwc_attach(device_t dev) } if (i >= MAC_RESET_TIMEOUT) { device_printf(sc->dev, "Can't reset DWC.\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1646,8 +1648,10 @@ dwc_attach(device_t dev) reg &= ~(MODE_ST | MODE_SR); WRITE4(sc, OPERATION_MODE, reg); - if (setup_dma(sc)) - return (ENXIO); + if (setup_dma(sc)) { + bus_release_resources(dev, dwc_spec, sc->res); + return (ENXIO); + } /* Setup addresses */ WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr); @@ -1663,6 +1667,7 @@ dwc_attach(device_t dev) NULL, dwc_intr, sc, &sc->intr_cookie); if (error != 0) { device_printf(dev, "could not setup interrupt handler.\n"); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } @@ -1688,6 +1693,8 @@ dwc_attach(device_t dev) if (error != 0) { device_printf(dev, "PHY attach failed\n"); + bus_teardown_intr(dev, sc->res[1], sc->intr_cookie); + bus_release_resources(dev, dwc_spec, sc->res); return (ENXIO); } sc->mii_softc = device_get_softc(sc->miibus);