diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-05-13 21:28:00 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-05-13 21:28:00 +0000 |
commit | 69b0b0af7e5c464c2e9af522067fd3b35fe4b9b2 (patch) | |
tree | f5569cd37284a2183faa310296685986daaffdc6 /sys/arch | |
parent | 647ead7aca40107aaa5e9c855681c521abc66096 (diff) |
free(9) sizes.
From miod@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/dev/sgmap_common.c | 6 | ||||
-rw-r--r-- | sys/arch/alpha/include/bus.h | 3 | ||||
-rw-r--r-- | sys/arch/alpha/isa/isadma_bounce.c | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/sys/arch/alpha/dev/sgmap_common.c b/sys/arch/alpha/dev/sgmap_common.c index c67150e81bd..71015671c2b 100644 --- a/sys/arch/alpha/dev/sgmap_common.c +++ b/sys/arch/alpha/dev/sgmap_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmap_common.c,v 1.14 2014/12/09 06:58:28 doug Exp $ */ +/* $OpenBSD: sgmap_common.c,v 1.15 2019/05/13 21:27:59 mpi Exp $ */ /* $NetBSD: sgmap_common.c,v 1.13 2000/06/29 09:02:57 mrg Exp $ */ /*- @@ -150,6 +150,8 @@ alpha_sgmap_dmamap_setup(map, nsegments, flags) { map->_dm_cookie = mallocarray(nsegments, sizeof(struct extent_region), M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK); + if (map->_dm_cookie != NULL) + map->_dm_cookiesize = nsegments * sizeof(struct extent_region); return (map->_dm_cookie == NULL); } @@ -187,7 +189,7 @@ void alpha_sgmap_dmamap_teardown(map) bus_dmamap_t map; { - free(map->_dm_cookie, M_DEVBUF, 0); + free(map->_dm_cookie, M_DEVBUF, map->_dm_cookiesize); } void diff --git a/sys/arch/alpha/include/bus.h b/sys/arch/alpha/include/bus.h index 3f623feee93..653a141df1a 100644 --- a/sys/arch/alpha/include/bus.h +++ b/sys/arch/alpha/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.31 2017/05/08 00:27:45 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.32 2019/05/13 21:27:59 mpi Exp $ */ /* $NetBSD: bus.h,v 1.10 1996/12/02 22:19:32 cgd Exp $ */ /* @@ -648,6 +648,7 @@ struct alpha_bus_dmamap { * Private cookie to be used by the DMA back-end. */ void *_dm_cookie; + size_t _dm_cookiesize; /* size allocated for _dm_cookie */ /* * The DMA window that we ended up being mapped in. diff --git a/sys/arch/alpha/isa/isadma_bounce.c b/sys/arch/alpha/isa/isadma_bounce.c index 4f1ca9a23e2..b1f8f01f340 100644 --- a/sys/arch/alpha/isa/isadma_bounce.c +++ b/sys/arch/alpha/isa/isadma_bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isadma_bounce.c,v 1.12 2015/09/27 10:12:09 semarie Exp $ */ +/* $OpenBSD: isadma_bounce.c,v 1.13 2019/05/13 21:27:59 mpi Exp $ */ /* $NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $ */ /*- @@ -115,6 +115,7 @@ isadma_bounce_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, map = *dmamp; map->_dm_cookie = NULL; + map->_dm_cookiesize = 0; cookiesize = sizeof(*cookie); @@ -156,6 +157,7 @@ isadma_bounce_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, cookie = (struct isadma_bounce_cookie *)cookiestore; cookie->id_flags = cookieflags; map->_dm_cookie = cookie; + map->_dm_cookiesize = cookiesize; if (cookieflags & ID_MIGHT_NEED_BOUNCE) { /* @@ -190,7 +192,7 @@ isadma_bounce_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map) if (cookie->id_flags & ID_HAS_BOUNCE) isadma_bounce_free_bouncebuf(t, map); - free(cookie, M_DEVBUF, 0); + free(cookie, M_DEVBUF, map->_dm_cookiesize); _bus_dmamap_destroy(t, map); } |