diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-12-16 12:43:55 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-12-16 12:43:55 +0000 |
commit | 548add9332b152d532afc8aa58db65a86794e30c (patch) | |
tree | 6aaac9937c2aee3267a8e9b83011dc3ff9a83b68 | |
parent | 802b7737cb634b0739471c1ee0c6d69917b3ac98 (diff) |
Correctly count number of segments in _bus_dmamap_load(). Initialize ds_addr
to 0UL instead of NULL while there.
Tested by & help from dlg@.
-rw-r--r-- | sys/arch/sparc64/sparc64/machdep.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index ca690576f9f..8c115a443cf 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.102 2007/11/16 20:51:29 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.103 2007/12/16 12:43:54 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1122,9 +1122,9 @@ _bus_dmamap_load(t, t0, map, buf, buflen, p, flags) */ map->dm_mapsize = buflen; i = 0; - map->dm_segs[i].ds_addr = NULL; + map->dm_segs[i].ds_addr = 0UL; map->dm_segs[i].ds_len = 0; - while (sgsize > 0 && i < map->_dm_segcnt) { + while (sgsize > 0) { paddr_t pa; (void) pmap_extract(pmap_kernel(), vaddr, &pa); @@ -1138,11 +1138,13 @@ _bus_dmamap_load(t, t0, map, buf, buflen, p, flags) map->dm_segs[i].ds_len += NBPG; continue; } - map->dm_segs[++i].ds_addr = pa; + if (++i > map->_dm_segcnt) + return (EFBIG); + map->dm_segs[i].ds_addr = pa; map->dm_segs[i].ds_len = NBPG; } /* Is this what the above comment calls "one segment"? */ - map->dm_nsegs = i; + map->dm_nsegs = i + 1; /* Mapping is bus dependent */ return (0); @@ -1404,7 +1406,7 @@ _bus_dmamem_alloc(t, t0, size, alignment, boundary, segs, nsegs, rsegs, flags) * Compute the location, size, and number of segments actually * returned by the VM code. */ - segs[0].ds_addr = NULL; /* UPA does not map things */ + segs[0].ds_addr = 0UL; /* UPA does not map things */ segs[0].ds_len = size; *rsegs = 1; |