diff options
author | ru <ru@FreeBSD.org> | 2005-09-16 11:25:19 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-09-16 11:25:19 +0000 |
commit | ffd86537c18a9461b7ba5750e9c1614efab9e102 (patch) | |
tree | 28693ec03ccca1e33bd2724f25f53e25086d4948 /sys/dev/en | |
parent | c71407b5890e69c4a1adc0e0936f0d7e9cd24be4 (diff) | |
download | FreeBSD-src-ffd86537c18a9461b7ba5750e9c1614efab9e102.zip FreeBSD-src-ffd86537c18a9461b7ba5750e9c1614efab9e102.tar.gz |
Fix "struct ifnet" leaks when attach() fails in the middle.
Diffstat (limited to 'sys/dev/en')
-rw-r--r-- | sys/dev/en/if_en_pci.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c index 77724d4..bfff233 100644 --- a/sys/dev/en/if_en_pci.c +++ b/sys/dev/en/if_en_pci.c @@ -199,8 +199,11 @@ en_pci_attach(device_t dev) sc = device_get_softc(dev); scp = (struct en_pci_softc *)sc; sc->ifp = if_alloc(IFT_ATM); - if (sc->ifp == NULL) - return (ENOSPC); + if (sc->ifp == NULL) { + device_printf(dev, "can not if_alloc()\n"); + error = ENOSPC; + goto fail; + } if_initname(sc->ifp, device_get_name(dev), device_get_unit(dev)); @@ -220,6 +223,7 @@ en_pci_attach(device_t dev) RF_ACTIVE); if (scp->res == NULL) { device_printf(dev, "could not map memory\n"); + if_free(sc->ifp); error = ENXIO; goto fail; } @@ -237,6 +241,7 @@ en_pci_attach(device_t dev) if (scp->irq == NULL) { device_printf(dev, "could not map interrupt\n"); bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res); + if_free(sc->ifp); error = ENXIO; goto fail; } @@ -267,6 +272,7 @@ en_pci_attach(device_t dev) bus_teardown_intr(dev, scp->irq, scp->ih); bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq); bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res); + if_free(sc->ifp); goto fail; } @@ -283,6 +289,7 @@ en_pci_attach(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq); bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res); en_destroy(sc); + if_free(sc->ifp); goto fail; } |