summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/lge/if_lge.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index 1313990..438a501 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -535,7 +535,6 @@ lge_attach(dev)
ifp = sc->lge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
- lge_free_jumbo_mem(sc);
error = ENOSPC;
goto fail;
}
@@ -562,7 +561,6 @@ lge_attach(dev)
if (mii_phy_probe(dev, &sc->lge_miibus,
lge_ifmedia_upd, lge_ifmedia_sts)) {
device_printf(dev, "MII without any PHY!\n");
- lge_free_jumbo_mem(sc);
error = ENXIO;
goto fail;
}
@@ -583,6 +581,7 @@ lge_attach(dev)
return (0);
fail:
+ lge_free_jumbo_mem(sc);
if (sc->lge_ldata)
contigfree(sc->lge_ldata,
sizeof(struct lge_list_data), M_DEVBUF);
@@ -804,10 +803,19 @@ static void
lge_free_jumbo_mem(sc)
struct lge_softc *sc;
{
- int i;
struct lge_jpool_entry *entry;
- for (i = 0; i < LGE_JSLOTS; i++) {
+ if (sc->lge_cdata.lge_jumbo_buf == NULL)
+ return;
+
+ while ((entry = SLIST_FIRST(&sc->lge_jinuse_listhead))) {
+ device_printf(sc->lge_dev,
+ "asked to free buffer that is in use!\n");
+ SLIST_REMOVE_HEAD(&sc->lge_jinuse_listhead, jpool_entries);
+ SLIST_INSERT_HEAD(&sc->lge_jfree_listhead, entry,
+ jpool_entries);
+ }
+ while (!SLIST_EMPTY(&sc->lge_jfree_listhead)) {
entry = SLIST_FIRST(&sc->lge_jfree_listhead);
SLIST_REMOVE_HEAD(&sc->lge_jfree_listhead, jpool_entries);
free(entry, M_DEVBUF);
OpenPOWER on IntegriCloud