diff --git a/sys/dev/ieee1394/fwdma.c b/sys/dev/ieee1394/fwdma.c index 5dc86a019522..358ad9da8595 100644 --- a/sys/dev/ieee1394/fwdma.c +++ b/sys/dev/ieee1394/fwdma.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwdma.c,v 1.16 2010/05/23 18:56:58 christos Exp $ */ +/* $NetBSD: fwdma.c,v 1.17 2018/12/13 16:38:26 jakllsch Exp $ */ /*- * Copyright (c) 2003 * Hidetoshi Shimokawa. All rights reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fwdma.c,v 1.16 2010/05/23 18:56:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fwdma.c,v 1.17 2018/12/13 16:38:26 jakllsch Exp $"); #if defined(__FreeBSD__) __FBSDID("$FreeBSD: src/sys/dev/firewire/fwdma.c,v 1.9 2007/06/06 14:31:36 simokawa Exp $"); #endif @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD: src/sys/dev/firewire/fwdma.c,v 1.9 2007/06/06 14:31:36 simok #include #include #include +#include #include #include @@ -108,11 +109,21 @@ fwdma_malloc(device_t dev, bus_dma_tag_t dmat, bus_dmamap_t *dmamap, void fwdma_free(bus_dma_tag_t dmat, bus_dmamap_t dmamap, void *vaddr) { + bus_dma_segment_t *segs; + /* XXX we shouldn't pass around the segs in the dmamap */ + const bus_size_t mapsize = dmamap->dm_mapsize; + const int nsegs = dmamap->dm_nsegs; + const size_t segssz = sizeof(bus_dma_segment_t) * nsegs; + segs = kmem_alloc(segssz, KM_SLEEP); + memcpy(segs, dmamap->dm_segs, segssz); + bus_dmamap_unload(dmat, dmamap); - bus_dmamem_unmap(dmat, vaddr, dmamap->dm_mapsize); - bus_dmamem_free(dmat, dmamap->dm_segs, dmamap->dm_nsegs); + bus_dmamem_unmap(dmat, vaddr, mapsize); + bus_dmamem_free(dmat, segs, nsegs); bus_dmamap_destroy(dmat, dmamap); + + kmem_free(segs, segssz); }