iwn - Clean up memory freeing.
authorJoe Talbott <josepht@dragonflybsd.org>
Sun, 25 Jul 2010 22:27:29 +0000 (18:27 -0400)
committerJoe Talbott <josepht@dragonflybsd.org>
Fri, 6 Aug 2010 19:35:21 +0000 (15:35 -0400)
* Mark variables with NULL after freeing.
* Properly free dma memory.

sys/dev/netif/iwn/if_iwn.c

index 1a6f826..5dc3b46 100644 (file)
@@ -854,8 +854,10 @@ iwn_cleanup(device_t dev)
                        iwn_free_tx_ring(sc, &sc->txq[i]);
        iwn_free_sched(sc);
        iwn_free_kw(sc);
-       if (sc->ict != NULL)
+       if (sc->ict != NULL) {
                iwn_free_ict(sc);
+               sc->ict = NULL;
+       }
        iwn_free_fwmem(sc);
 
        if (sc->irq != NULL) {
@@ -863,13 +865,18 @@ iwn_cleanup(device_t dev)
                bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
                if (sc->irq_rid == 1)
                        pci_release_msi(dev);
+               sc->irq = NULL;
        }
 
-       if (sc->mem != NULL)
+       if (sc->mem != NULL) {
                bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
+               sc->mem = NULL;
+       }
 
-       if (ifp != NULL)
+       if (ifp != NULL) {
                if_free(ifp);
+               sc->sc_ifp = NULL;
+       }
 
        IWN_LOCK_DESTROY(sc);
        return 0;
@@ -1178,8 +1185,9 @@ iwn_dma_contig_free(struct iwn_dma_info *dma)
                                    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
                                bus_dmamap_unload(dma->tag, dma->map);
                        }
-                       bus_dmamem_free(dma->tag, &dma->vaddr, dma->map);
+                       bus_dmamap_destroy(dma->tag, dma->map);
                }
+               bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
                bus_dma_tag_destroy(dma->tag);
        }
 }