diff options
author | nyan <nyan@FreeBSD.org> | 2002-02-19 14:58:11 +0000 |
---|---|---|
committer | nyan <nyan@FreeBSD.org> | 2002-02-19 14:58:11 +0000 |
commit | 8da9b74a31a6b5cd0d592043ef91c90e20789e30 (patch) | |
tree | 70f3efe2c62e63759ca9511777e8c0ee1e32ef22 | |
parent | 3254728d11a52e6cf489ea1f3e29d3490e0e6e26 (diff) | |
download | FreeBSD-src-8da9b74a31a6b5cd0d592043ef91c90e20789e30.zip FreeBSD-src-8da9b74a31a6b5cd0d592043ef91c90e20789e30.tar.gz |
Release allocated memory and bus_space_handle on an error.
Reviewed by: jhay
-rw-r--r-- | sys/dev/puc/puc.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sys/dev/puc/puc.c b/sys/dev/puc/puc.c index 563633f..2d2610f 100644 --- a/sys/dev/puc/puc.c +++ b/sys/dev/puc/puc.c @@ -287,8 +287,10 @@ puc_pci_attach(device_t dev) } else { rle->res = malloc(sizeof(struct resource), M_DEVBUF, M_WAITOK | M_ZERO); - if (rle->res == NULL) + if (rle->res == NULL) { + free(pdev, M_DEVBUF); return (ENOMEM); + } rle->res->r_start = rman_get_start(res) + sc->sc_desc->ports[i].offset; @@ -304,8 +306,16 @@ puc_pci_attach(device_t dev) childunit = puc_find_free_unit(typestr); sc->sc_ports[i].dev = device_add_child(dev, typestr, childunit); - if (sc->sc_ports[i].dev == NULL) + if (sc->sc_ports[i].dev == NULL) { + if (sc->barmuxed) { + bus_space_unmap(rman_get_bustag(rle->res), + rman_get_bushandle(rle->res), + 8); + free(rle->res, M_DEVBUF); + free(pdev, M_DEVBUF); + } continue; + } device_set_ivars(sc->sc_ports[i].dev, pdev); device_set_desc(sc->sc_ports[i].dev, sc->sc_desc->name); if (!bootverbose) @@ -317,7 +327,15 @@ puc_pci_attach(device_t dev) sc->sc_desc->ports[i].offset); print_resource_list(&pdev->resources); #endif - device_probe_and_attach(sc->sc_ports[i].dev); + if (device_probe_and_attach(sc->sc_ports[i].dev) != 0) { + if (sc->barmuxed) { + bus_space_unmap(rman_get_bustag(rle->res), + rman_get_bushandle(rle->res), + 8); + free(rle->res, M_DEVBUF); + free(pdev, M_DEVBUF); + } + } } #ifdef PUC_DEBUG |