diff options
author | John Baldwin <jhb@FreeBSD.org> | 2023-02-15 21:34:00 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-09-06 21:56:09 +0000 |
commit | a3105e25800cfc8c8eccffb002cfbd2358a18ab1 (patch) | |
tree | ff989ec41740b4bf1f9c2720b14ad59a0fb15957 | |
parent | fe6953f70fab1f89de198d3dbc885d6f89a44883 (diff) | |
download | src-a3105e25800cfc8c8eccffb002cfbd2358a18ab1.tar.gz src-a3105e25800cfc8c8eccffb002cfbd2358a18ab1.zip |
cxgbe: Don't leak memory resource if t4iov attach fails.
Co-authored by: np
Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D38580
(cherry picked from commit d2070e5fa983281e94a338d6e87eb29c7dd28505)
-rw-r--r-- | sys/dev/cxgbe/t4_iov.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/dev/cxgbe/t4_iov.c b/sys/dev/cxgbe/t4_iov.c index ac58f9ca0a70..b063bda233b9 100644 --- a/sys/dev/cxgbe/t4_iov.c +++ b/sys/dev/cxgbe/t4_iov.c @@ -192,6 +192,7 @@ t4iov_attach(device_t dev) { struct t4iov_softc *sc; uint32_t pl_rev, whoami; + int error; sc = device_get_softc(dev); sc->sc_dev = dev; @@ -215,10 +216,18 @@ t4iov_attach(device_t dev) sc->sc_main = pci_find_dbsf(pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), 4); - if (sc->sc_main == NULL) + if (sc->sc_main == NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, + sc->regs_res); return (ENXIO); - if (T4_IS_MAIN_READY(sc->sc_main) == 0) - return (t4iov_attach_child(dev)); + } + if (T4_IS_MAIN_READY(sc->sc_main) == 0) { + error = t4iov_attach_child(dev); + if (error != 0) + bus_release_resource(dev, SYS_RES_MEMORY, sc->regs_rid, + sc->regs_res); + return (error); + } return (0); } |