Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Oct 2013 15:00:04 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@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: r255990 - stable/9/sys/powerpc/powerpc
Message-ID:  <201310021500.r92F04kZ093141@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Wed Oct  2 15:00:04 2013
New Revision: 255990
URL: http://svnweb.freebsd.org/changeset/base/255990

Log:
  MFC r255614,255639:
  Fix bug in busdma: if segs is a preexisting buffer, we memcpy it
  into the DMA map. The length of the buffer had not yet been
  initialized, however, so this would copy gibberish unless it
  happened to be right by chance. This bug mostly only affected
  systems with IOMMUs.

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

Modified: stable/9/sys/powerpc/powerpc/busdma_machdep.c
==============================================================================
--- stable/9/sys/powerpc/powerpc/busdma_machdep.c	Wed Oct  2 14:43:17 2013	(r255989)
+++ stable/9/sys/powerpc/powerpc/busdma_machdep.c	Wed Oct  2 15:00:04 2013	(r255990)
@@ -843,16 +843,19 @@ _bus_dmamap_complete(bus_dma_tag_t dmat,
 		     bus_dma_segment_t *segs, int nsegs, int error)
 {
 
+	map->nsegs = nsegs;
 	if (segs != NULL)
 		memcpy(map->segments, segs, map->nsegs*sizeof(segs[0]));
-	else
-		segs = map->segments;
-	map->nsegs = nsegs;
 	if (dmat->iommu != NULL)
 		IOMMU_MAP(dmat->iommu, map->segments, &map->nsegs,
 		    dmat->lowaddr, dmat->highaddr, dmat->alignment,
 		    dmat->boundary, dmat->iommu_cookie);
 
+	if (segs != NULL)
+		memcpy(segs, map->segments, map->nsegs*sizeof(segs[0]));
+	else
+		segs = map->segments;
+
 	return (segs);
 }
 



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