From e8510cd74761a432114ed69f500089ce2b8434a0 Mon Sep 17 00:00:00 2001 From: miod Date: Wed, 24 Dec 2014 22:48:27 +0000 Subject: [PATCH] Pass real sizes to free(). --- sys/arch/aviion/aviion/bus_dma.c | 7 +++++-- sys/arch/aviion/aviion/disksubr.c | 4 ++-- sys/arch/aviion/dev/dma.c | 4 ++-- sys/arch/aviion/dev/vme.c | 4 ++-- sys/arch/m88k/m88k/softintr.c | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/arch/aviion/aviion/bus_dma.c b/sys/arch/aviion/aviion/bus_dma.c index b19db9be109..ab4fb8dba38 100644 --- a/sys/arch/aviion/aviion/bus_dma.c +++ b/sys/arch/aviion/aviion/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.9 2014/11/16 12:30:56 deraadt Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.10 2014/12/24 22:48:27 miod Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -112,8 +112,11 @@ bus_dmamap_destroy(t, map) bus_dma_tag_t t; bus_dmamap_t map; { + size_t mapsize; - free(map, M_DEVBUF, 0); + mapsize = sizeof(struct m88k_bus_dmamap) + + (sizeof(bus_dma_segment_t) * (map->_dm_segcnt - 1)); + free(map, M_DEVBUF, mapsize); } /* diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index d5f95c0b8b1..ec99fce60b8 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.59 2014/07/12 18:44:41 tedu Exp $ */ +/* $OpenBSD: disksubr.c,v 1.60 2014/12/24 22:48:27 miod Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -450,7 +450,7 @@ readvditlabel(struct buf *bp, void (*strat)(struct buf *), struct disklabel *lp, } done: - free(vdit_storage, M_DEVBUF, 0); + free(vdit_storage, M_DEVBUF, vdit_size); if (sbp != NULL) { sbp->b_flags |= B_INVAL; brelse(sbp); diff --git a/sys/arch/aviion/dev/dma.c b/sys/arch/aviion/dev/dma.c index 0555d99c1d6..66329451895 100644 --- a/sys/arch/aviion/dev/dma.c +++ b/sys/arch/aviion/dev/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.2 2014/07/12 18:44:41 tedu Exp $ */ +/* $OpenBSD: dma.c,v 1.3 2014/12/24 22:48:27 miod Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -139,7 +139,7 @@ dma_intr(void *v) if (req->cbdone != NULL) (*req->cbdone)(req->cbarg); - free(req, M_DEVBUF, 0); + free(req, M_DEVBUF, sizeof *req); } else { req->mem += req->lastcnt; } diff --git a/sys/arch/aviion/dev/vme.c b/sys/arch/aviion/dev/vme.c index 90fc6b86e6f..8384063675d 100644 --- a/sys/arch/aviion/dev/vme.c +++ b/sys/arch/aviion/dev/vme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vme.c,v 1.15 2014/11/16 12:30:56 deraadt Exp $ */ +/* $OpenBSD: vme.c,v 1.16 2014/12/24 22:48:27 miod Exp $ */ /* * Copyright (c) 2006, 2007, 2010 Miodrag Vallat. * @@ -836,7 +836,7 @@ vmebus_get_bst(struct device *vsc, u_int aspace, u_int dspace, void vmebus_release_bst(struct device *vsc, bus_space_tag_t b) { - free((void *)b, M_DEVBUF, 0); + free((void *)b, M_DEVBUF, sizeof(struct aviion_bus_space_tag)); } /* diff --git a/sys/arch/m88k/m88k/softintr.c b/sys/arch/m88k/m88k/softintr.c index c8e6ba3abb1..fb466c67a2a 100644 --- a/sys/arch/m88k/m88k/softintr.c +++ b/sys/arch/m88k/m88k/softintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softintr.c,v 1.4 2014/07/12 18:44:42 tedu Exp $ */ +/* $OpenBSD: softintr.c,v 1.5 2014/12/24 22:48:27 miod Exp $ */ /* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */ /* @@ -147,7 +147,7 @@ softintr_disestablish(void *arg) } mtx_leave(&siq->siq_mtx); - free(sih, M_DEVBUF, 0); + free(sih, M_DEVBUF, sizeof(*sih)); } /* -- 2.20.1