em/emx: Fix up detach path
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 8 Aug 2012 05:21:20 +0000 (13:21 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 8 Aug 2012 05:21:20 +0000 (13:21 +0800)
- We could release management control only if PCI BAR is mapped
- Release multicase array memory

sys/dev/netif/em/if_em.c
sys/dev/netif/emx/if_emx.c

index e3b959d..0e55bb7 100644 (file)
@@ -870,7 +870,7 @@ em_detach(device_t dev)
                lwkt_serialize_exit(ifp->if_serializer);
 
                ether_ifdetach(ifp);
                lwkt_serialize_exit(ifp->if_serializer);
 
                ether_ifdetach(ifp);
-       } else {
+       } else if (adapter->memory != NULL) {
                em_rel_hw_control(adapter);
        }
        bus_generic_detach(dev);
                em_rel_hw_control(adapter);
        }
        bus_generic_detach(dev);
@@ -896,6 +896,9 @@ em_detach(device_t dev)
        if (adapter->sysctl_tree != NULL)
                sysctl_ctx_free(&adapter->sysctl_ctx);
 
        if (adapter->sysctl_tree != NULL)
                sysctl_ctx_free(&adapter->sysctl_ctx);
 
+       if (adapter->mta != NULL)
+               kfree(adapter->mta, M_DEVBUF);
+
        return (0);
 }
 
        return (0);
 }
 
index b8526ea..50cf712 100644 (file)
@@ -788,7 +788,7 @@ emx_detach(device_t dev)
                ifnet_deserialize_all(ifp);
 
                ether_ifdetach(ifp);
                ifnet_deserialize_all(ifp);
 
                ether_ifdetach(ifp);
-       } else {
+       } else if (sc->memory != NULL) {
                emx_rel_hw_control(sc);
        }
        bus_generic_detach(dev);
                emx_rel_hw_control(sc);
        }
        bus_generic_detach(dev);
@@ -812,6 +812,9 @@ emx_detach(device_t dev)
        if (sc->sysctl_tree != NULL)
                sysctl_ctx_free(&sc->sysctl_ctx);
 
        if (sc->sysctl_tree != NULL)
                sysctl_ctx_free(&sc->sysctl_ctx);
 
+       if (sc->mta != NULL)
+               kfree(sc->mta, M_DEVBUF);
+
        return (0);
 }
 
        return (0);
 }