From d2f7ab28daf6bc7f93eb290728f89c7d713ca0ce Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 16 Sep 2005 11:11:51 +0000 Subject: 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. --- sys/pci/if_sf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/pci/if_sf.c') diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c index e14ce26..fa7eb83 100644 --- a/sys/pci/if_sf.c +++ b/sys/pci/if_sf.c @@ -766,7 +766,6 @@ sf_attach(dev) if (error) { device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); - if_free(ifp); goto fail; } @@ -802,8 +801,9 @@ sf_detach(dev) SF_UNLOCK(sc); callout_drain(&sc->sf_stat_callout); ether_ifdetach(ifp); - if_free(ifp); } + if (ifp) + if_free(ifp); if (sc->sf_miibus) device_delete_child(dev, sc->sf_miibus); bus_generic_detach(dev); -- cgit v1.1