Free the dma map -after- it's checked, not before. Or you'll be

potentially referencing already-freed memory.
This commit is contained in:
Adrian Chadd 2012-11-02 05:22:32 +00:00
parent ffdbf9da3b
commit 0fd5c74381
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242465

View file

@ -549,7 +549,6 @@ int
bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
{
_busdma_free_dmamap(map);
if (STAILQ_FIRST(&map->bpages) != NULL) {
CTR3(KTR_BUSDMA, "%s: tag %p error %d",
__func__, dmat, EBUSY);
@ -558,6 +557,7 @@ bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
if (dmat->bounce_zone)
dmat->bounce_zone->map_count--;
dmat->map_count--;
_busdma_free_dmamap(map);
CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
return (0);
}