Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jun 2013 19:45:27 +0000 (UTC)
From:      Scott Long <scottl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r251860 - stable/9/sys/mips/mips
Message-ID:  <201306171945.r5HJjR12015520@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Mon Jun 17 19:45:27 2013
New Revision: 251860
URL: http://svnweb.freebsd.org/changeset/base/251860

Log:
  MFC r242465:
  Free the dma map -after- it's checked, not before. Or you'll be
  potentially referencing already-freed memory.
  
  MFC r242466:
  Drop this from 500 to 128, to save a little space on memory constrained
  platforms.
  
  Submitted by:	adrian
  Obtained from:	Netflix

Modified:
  stable/9/sys/mips/mips/busdma_machdep.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/mips/mips/busdma_machdep.c
==============================================================================
--- stable/9/sys/mips/mips/busdma_machdep.c	Mon Jun 17 19:31:03 2013	(r251859)
+++ stable/9/sys/mips/mips/busdma_machdep.c	Mon Jun 17 19:45:27 2013	(r251860)
@@ -152,7 +152,7 @@ static STAILQ_HEAD(, bus_dmamap) bounce_
 static TAILQ_HEAD(,bus_dmamap) dmamap_freelist = 
 	TAILQ_HEAD_INITIALIZER(dmamap_freelist);
 
-#define BUSDMA_STATIC_MAPS	500
+#define BUSDMA_STATIC_MAPS	128
 static struct bus_dmamap map_pool[BUSDMA_STATIC_MAPS];
 
 static struct mtx busdma_mtx;
@@ -533,7 +533,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);
@@ -542,6 +541,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?201306171945.r5HJjR12015520>