From 45e412c12b002a0ba5d2aca2eaca5bfb50be313c Mon Sep 17 00:00:00 2001 From: miod Date: Tue, 23 Dec 2014 21:39:12 +0000 Subject: [PATCH] Pass real sizes to free() --- sys/arch/vax/if/if_qe.c | 4 ++-- sys/arch/vax/mbus/legss.c | 4 ++-- sys/arch/vax/qbus/uda.c | 4 ++-- sys/arch/vax/vax/bus_dma.c | 7 +++++-- sys/arch/vax/vax/softintr.c | 4 ++-- sys/arch/vax/vsa/gpx.c | 4 ++-- sys/arch/vax/vsa/lcg.c | 4 ++-- sys/arch/vax/vsa/lcspx.c | 4 ++-- sys/arch/vax/vsa/smg.c | 8 ++++---- 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/sys/arch/vax/if/if_qe.c b/sys/arch/vax/if/if_qe.c index ebc8acdf500..7c39a82b204 100644 --- a/sys/arch/vax/if/if_qe.c +++ b/sys/arch/vax/if/if_qe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_qe.c,v 1.29 2014/12/22 02:26:54 tedu Exp $ */ +/* $OpenBSD: if_qe.c,v 1.30 2014/12/23 21:39:12 miod Exp $ */ /* $NetBSD: if_qe.c,v 1.51 2002/06/08 12:28:37 ragge Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. @@ -195,7 +195,7 @@ qematch(struct device *parent, struct cfdata *cf, void *aux) * All done with the bus resources. */ ubfree((void *)parent, &ui); - free(ring, M_TEMP, 0); + free(ring, M_TEMP, PROBESIZE); return 1; } diff --git a/sys/arch/vax/mbus/legss.c b/sys/arch/vax/mbus/legss.c index 7a078a20a9b..833059c9f20 100644 --- a/sys/arch/vax/mbus/legss.c +++ b/sys/arch/vax/mbus/legss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: legss.c,v 1.7 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: legss.c,v 1.8 2014/12/23 21:39:12 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -254,7 +254,7 @@ bad2: vax_unmap_physmem(scr->ss_vram, (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG); bad1: - free(scr, M_DEVBUF, 0); + free(scr, M_DEVBUF, sizeof(struct legss_screen)); } /* diff --git a/sys/arch/vax/qbus/uda.c b/sys/arch/vax/qbus/uda.c index b4145f98f5d..91179b2d827 100644 --- a/sys/arch/vax/qbus/uda.c +++ b/sys/arch/vax/qbus/uda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uda.c,v 1.10 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: uda.c,v 1.11 2014/12/23 21:39:12 miod Exp $ */ /* $NetBSD: uda.c,v 1.36 2000/06/04 06:17:05 matt Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -331,7 +331,7 @@ udaready(uu) return 0; mscp_dgo(sc->sc_softc, mxi); sc->sc_inq--; - free(uu, M_DEVBUF, 0); + free(uu, M_DEVBUF, sizeof(struct uba_unit)); return 1; } diff --git a/sys/arch/vax/vax/bus_dma.c b/sys/arch/vax/vax/bus_dma.c index e6519b5d9d4..f9661503e1a 100644 --- a/sys/arch/vax/vax/bus_dma.c +++ b/sys/arch/vax/vax/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.31 2014/11/16 12:30:59 deraadt Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.32 2014/12/23 21:39:12 miod Exp $ */ /* $NetBSD: bus_dma.c,v 1.5 1999/11/13 00:32:20 thorpej Exp $ */ /*- @@ -129,6 +129,7 @@ _bus_dmamap_destroy(t, map) bus_dma_tag_t t; bus_dmamap_t map; { + size_t mapsize; #ifdef DEBUG_DMA printf("dmamap_destroy: t=%p map=%p\n", t, map); @@ -137,7 +138,9 @@ _bus_dmamap_destroy(t, map) if (map->dm_nsegs > 0) printf("bus_dmamap_destroy() called for map with valid mappings\n"); #endif /* DIAGNOSTIC */ - free(map, M_DEVBUF, 0); + mapsize = sizeof(struct vax_bus_dmamap) + + (sizeof(bus_dma_segment_t) * (map->_dm_segcnt - 1)); + free(map, M_DEVBUF, mapsize); } /* diff --git a/sys/arch/vax/vax/softintr.c b/sys/arch/vax/vax/softintr.c index 812e10f3cf7..6f7555f7372 100644 --- a/sys/arch/vax/vax/softintr.c +++ b/sys/arch/vax/vax/softintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softintr.c,v 1.4 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: softintr.c,v 1.5 2014/12/23 21:39:12 miod Exp $ */ /* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */ /* @@ -149,7 +149,7 @@ softintr_disestablish(void *arg) } mtx_leave(&siq->siq_mtx); - free(sih, M_DEVBUF, 0); + free(sih, M_DEVBUF, sizeof(*sih)); } /* diff --git a/sys/arch/vax/vsa/gpx.c b/sys/arch/vax/vsa/gpx.c index 600a1518d0a..ad2b732ce31 100644 --- a/sys/arch/vax/vsa/gpx.c +++ b/sys/arch/vax/vsa/gpx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpx.c,v 1.24 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: gpx.c,v 1.25 2014/12/23 21:39:12 miod Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -385,7 +385,7 @@ bad3: bad2: vax_unmap_physmem((vaddr_t)scr->ss_adder, 1); bad1: - free(scr, M_DEVBUF, 0); + free(scr, M_DEVBUF, sizeof(struct gpx_screen)); } /* diff --git a/sys/arch/vax/vsa/lcg.c b/sys/arch/vax/vsa/lcg.c index c3f608ba21e..f1991c16005 100644 --- a/sys/arch/vax/vsa/lcg.c +++ b/sys/arch/vax/vsa/lcg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcg.c,v 1.22 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: lcg.c,v 1.23 2014/12/23 21:39:12 miod Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -317,7 +317,7 @@ fail3: fail2: vax_unmap_physmem((vaddr_t)ss->ss_addr, ss->ss_fbsize / VAX_NBPG); fail1: - free(ss, M_DEVBUF, 0); + free(ss, M_DEVBUF, sizeof(*ss)); } /* diff --git a/sys/arch/vax/vsa/lcspx.c b/sys/arch/vax/vsa/lcspx.c index 131a88fc5db..026e80733f4 100644 --- a/sys/arch/vax/vsa/lcspx.c +++ b/sys/arch/vax/vsa/lcspx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcspx.c,v 1.20 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: lcspx.c,v 1.21 2014/12/23 21:39:12 miod Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -367,7 +367,7 @@ fail2: vax_unmap_physmem((vaddr_t)ss->ss_ramdac[i], 1); vax_unmap_physmem(ss->ss_reg, LCSPX_REG_SIZE / VAX_NBPG); fail1: - free(ss, M_DEVBUF, 0); + free(ss, M_DEVBUF, sizeof(*ss)); } static __inline__ void diff --git a/sys/arch/vax/vsa/smg.c b/sys/arch/vax/vsa/smg.c index 768f33b6b3a..b39f75aac6f 100644 --- a/sys/arch/vax/vsa/smg.c +++ b/sys/arch/vax/vsa/smg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smg.c,v 1.27 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: smg.c,v 1.28 2014/12/23 21:39:12 miod Exp $ */ /* $NetBSD: smg.c,v 1.21 2000/03/23 06:46:44 thorpej Exp $ */ /* * Copyright (c) 2006, Miodrag Vallat @@ -294,7 +294,7 @@ smg_attach(struct device *parent, struct device *self, void *aux) (caddr_t)vax_map_physmem(SMADDR, SMSIZE / VAX_NBPG); if (scr->ss_addr == NULL) { printf(": can not map frame buffer\n"); - free(scr, M_DEVBUF, 0); + free(scr, M_DEVBUF, sizeof(*scr)); return; } @@ -304,7 +304,7 @@ smg_attach(struct device *parent, struct device *self, void *aux) printf(": can not map cursor chip\n"); vax_unmap_physmem((vaddr_t)scr->ss_addr, SMSIZE / VAX_NBPG); - free(scr, M_DEVBUF, 0); + free(scr, M_DEVBUF, sizeof(*scr)); return; } @@ -313,7 +313,7 @@ smg_attach(struct device *parent, struct device *self, void *aux) vax_unmap_physmem((vaddr_t)scr->ss_cursor, 1); vax_unmap_physmem((vaddr_t)scr->ss_addr, SMSIZE / VAX_NBPG); - free(scr, M_DEVBUF, 0); + free(scr, M_DEVBUF, sizeof(*scr)); return; } } -- 2.20.1