git: a3105e25800c - stable/13 - cxgbe: Don't leak memory resource if t4iov attach fails.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Sep 2023 21:56:40 UTC
The branch stable/13 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=a3105e25800cfc8c8eccffb002cfbd2358a18ab1
commit a3105e25800cfc8c8eccffb002cfbd2358a18ab1
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-02-15 21:34:00 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-09-06 21:56:09 +0000
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)
---
sys/dev/cxgbe/t4_iov.c | 15 ++++++++++++---
1 file 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);
}