Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Nov 2012 05:22:32 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242465 - head/sys/mips/mips
Message-ID:  <201211020522.qA25MWWG051963@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Fri Nov  2 05:22:32 2012
New Revision: 242465
URL: http://svn.freebsd.org/changeset/base/242465

Log:
  Free the dma map -after- it's checked, not before. Or you'll be
  potentially referencing already-freed memory.

Modified:
  head/sys/mips/mips/busdma_machdep.c

Modified: head/sys/mips/mips/busdma_machdep.c
==============================================================================
--- head/sys/mips/mips/busdma_machdep.c	Fri Nov  2 01:32:22 2012	(r242464)
+++ head/sys/mips/mips/busdma_machdep.c	Fri Nov  2 05:22:32 2012	(r242465)
@@ -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, b
 	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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211020522.qA25MWWG051963>