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_wb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/pci/if_wb.c') diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c index a6a677f..205e007 100644 --- a/sys/pci/if_wb.c +++ b/sys/pci/if_wb.c @@ -885,7 +885,6 @@ wb_attach(dev) if (error) { device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); - if_free(ifp); goto fail; } @@ -922,8 +921,9 @@ wb_detach(dev) if (device_is_attached(dev)) { wb_stop(sc); ether_ifdetach(ifp); - if_free(ifp); } + if (ifp) + if_free(ifp); if (sc->wb_miibus) device_delete_child(dev, sc->wb_miibus); bus_generic_detach(dev); -- cgit v1.1