summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_rl.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-09-16 11:11:51 +0000
committerru <ru@FreeBSD.org>2005-09-16 11:11:51 +0000
commitd2f7ab28daf6bc7f93eb290728f89c7d713ca0ce (patch)
treeeea8401041be885ba31c07333f6e0206b9d04ab0 /sys/pci/if_rl.c
parent02dbbd7982679f0c66e9ffa29caf799b5c1a3bde (diff)
downloadFreeBSD-src-d2f7ab28daf6bc7f93eb290728f89c7d713ca0ce.zip
FreeBSD-src-d2f7ab28daf6bc7f93eb290728f89c7d713ca0ce.tar.gz
Fix "struct ifnet" leaks when attach() fails in the middle, e.g.
when mii_phy_probe() or bus_setup_intr() fails. For drivers that call their detach() in this case, call if_free() there to cover this case too.
Diffstat (limited to 'sys/pci/if_rl.c')
-rw-r--r--sys/pci/if_rl.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c
index 3f650e3..556c1a1 100644
--- a/sys/pci/if_rl.c
+++ b/sys/pci/if_rl.c
@@ -986,7 +986,6 @@ rl_attach(device_t dev)
if (error) {
if_printf(ifp, "couldn't set up irq\n");
ether_ifdetach(ifp);
- if_free(ifp);
}
fail:
@@ -1008,24 +1007,23 @@ rl_detach(device_t dev)
{
struct rl_softc *sc;
struct ifnet *ifp;
- int attached;
sc = device_get_softc(dev);
ifp = sc->rl_ifp;
KASSERT(mtx_initialized(&sc->rl_mtx), ("rl mutex not initialized"));
- attached = device_is_attached(dev);
/* These should only be active if attach succeeded */
- if (attached) {
+ if (device_is_attached(dev)) {
RL_LOCK(sc);
rl_stop(sc);
RL_UNLOCK(sc);
ether_ifdetach(ifp);
- if_free(ifp);
}
#if 0
sc->suspended = 1;
#endif
+ if (ifp)
+ if_free(ifp);
if (sc->rl_miibus)
device_delete_child(dev, sc->rl_miibus);
bus_generic_detach(dev);
OpenPOWER on IntegriCloud