summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-09-09 19:47:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-09-09 19:47:12 +0000
commitde820668e1f24c4dedf0ad5ba06f6e2bfd70cecc (patch)
tree16b66f895bc469daf62368a2530aebb7e8f08206 /sys/dev
parent3ea7547c10c0bc514a8304a6ff39e79d23ac55cd (diff)
sizes for free(); ok semarie
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/agp.c16
-rw-r--r--sys/dev/pci/agp_amd.c6
-rw-r--r--sys/dev/pci/agp_i810.c16
3 files changed, 19 insertions, 19 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index decfe9b496d..cc28a79007a 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.45 2014/07/13 23:10:23 deraadt Exp $ */
+/* $OpenBSD: agp.c,v 1.46 2015/09/09 19:47:11 deraadt Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -240,7 +240,7 @@ agp_alloc_gatt(bus_dma_tag_t dmat, u_int32_t apsize)
if (agp_alloc_dmamem(dmat, gatt->ag_size, &gatt->ag_dmamap,
&gatt->ag_physical, &gatt->ag_dmaseg) != 0) {
- free(gatt, M_AGP, 0);
+ free(gatt, M_AGP, sizeof *gatt);
return (NULL);
}
@@ -248,7 +248,7 @@ agp_alloc_gatt(bus_dma_tag_t dmat, u_int32_t apsize)
(caddr_t *)&gatt->ag_virtual, BUS_DMA_NOWAIT) != 0) {
agp_free_dmamem(dmat, gatt->ag_size, gatt->ag_dmamap,
&gatt->ag_dmaseg);
- free(gatt, M_AGP, 0);
+ free(gatt, M_AGP, sizeof *gatt);
return (NULL);
}
@@ -262,7 +262,7 @@ agp_free_gatt(bus_dma_tag_t dmat, struct agp_gatt *gatt)
{
bus_dmamem_unmap(dmat, (caddr_t)gatt->ag_virtual, gatt->ag_size);
agp_free_dmamem(dmat, gatt->ag_size, gatt->ag_dmamap, &gatt->ag_dmaseg);
- free(gatt, M_AGP, 0);
+ free(gatt, M_AGP, sizeof *gatt);
}
int
@@ -340,7 +340,7 @@ agp_generic_alloc_memory(struct agp_softc *sc, int type, vsize_t size)
if (bus_dmamap_create(sc->sc_dmat, size, size / PAGE_SIZE + 1,
size, 0, BUS_DMA_NOWAIT, &mem->am_dmamap) != 0) {
- free(mem, M_AGP, 0);
+ free(mem, M_AGP, sizeof *mem);
return (NULL);
}
@@ -361,7 +361,7 @@ agp_generic_free_memory(struct agp_softc *sc, struct agp_memory *mem)
sc->sc_allocated -= mem->am_size;
TAILQ_REMOVE(&sc->sc_memory, mem, am_link);
bus_dmamap_destroy(sc->sc_dmat, mem->am_dmamap);
- free(mem, M_AGP, 0);
+ free(mem, M_AGP, sizeof *mem);
return (0);
}
@@ -401,7 +401,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
segs = mallocarray(nseg, sizeof *segs, M_AGP, M_WAITOK);
if ((error = bus_dmamem_alloc(sc->sc_dmat, mem->am_size, PAGE_SIZE, 0,
segs, nseg, &mem->am_nseg, BUS_DMA_ZERO | BUS_DMA_WAITOK)) != 0) {
- free(segs, M_AGP, 0);
+ free(segs, M_AGP, nseg * sizeof *segs);
rw_exit_write(&sc->sc_lock);
AGP_DPF("bus_dmamem_alloc failed %d\n", error);
return (error);
@@ -409,7 +409,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
if ((error = bus_dmamap_load_raw(sc->sc_dmat, mem->am_dmamap, segs,
mem->am_nseg, mem->am_size, BUS_DMA_WAITOK)) != 0) {
bus_dmamem_free(sc->sc_dmat, segs, mem->am_nseg);
- free(segs, M_AGP, 0);
+ free(segs, M_AGP, nseg * sizeof *segs);
rw_exit_write(&sc->sc_lock);
AGP_DPF("bus_dmamap_load failed %d\n", error);
return (error);
diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c
index e87b5b8b569..8152e74a751 100644
--- a/sys/dev/pci/agp_amd.c
+++ b/sys/dev/pci/agp_amd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_amd.c,v 1.20 2014/07/12 18:48:51 tedu Exp $ */
+/* $OpenBSD: agp_amd.c,v 1.21 2015/09/09 19:47:11 deraadt Exp $ */
/* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */
/*-
@@ -119,7 +119,7 @@ agp_amd_alloc_gatt(bus_dma_tag_t dmat, bus_size_t apsize)
if (agp_alloc_dmamem(dmat, gatt->ag_size, &gatt->ag_dmamap,
&gatt->ag_pdir, &gatt->ag_dmaseg) != 0) {
printf("failed to allocate GATT\n");
- free(gatt, M_AGP, 0);
+ free(gatt, M_AGP, sizeof *gatt);
return (NULL);
}
@@ -128,7 +128,7 @@ agp_amd_alloc_gatt(bus_dma_tag_t dmat, bus_size_t apsize)
printf("failed to map GATT\n");
agp_free_dmamem(dmat, gatt->ag_size, gatt->ag_dmamap,
&gatt->ag_dmaseg);
- free(gatt, M_AGP, 0);
+ free(gatt, M_AGP, sizeof *gatt);
return (NULL);
}
diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c
index 4dab7b8fc74..91c4b3f6f70 100644
--- a/sys/dev/pci/agp_i810.c
+++ b/sys/dev/pci/agp_i810.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_i810.c,v 1.89 2014/11/06 05:48:42 jsg Exp $ */
+/* $OpenBSD: agp_i810.c,v 1.90 2015/09/09 19:47:11 deraadt Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
@@ -519,7 +519,7 @@ out:
if (isc->gatt->ag_size != 0)
agp_free_dmamem(pa->pa_dmat, isc->gatt->ag_size,
isc->gatt->ag_dmamap, &isc->gatt->ag_dmaseg);
- free(isc->gatt, M_AGP, 0);
+ free(isc->gatt, M_AGP, sizeof (*isc->gatt));
}
if (isc->gtt_map != NULL)
vga_pci_bar_unmap(isc->gtt_map);
@@ -655,14 +655,14 @@ agp_i810_alloc_memory(void *softc, int type, vsize_t size)
*/
if ((mem->am_dmaseg = malloc(sizeof (*mem->am_dmaseg), M_AGP,
M_WAITOK | M_CANFAIL)) == NULL) {
- free(mem, M_AGP, 0);
+ free(mem, M_AGP, sizeof *mem);
return (NULL);
}
if ((error = agp_alloc_dmamem(sc->sc_dmat, size,
&mem->am_dmamap, &mem->am_physical, mem->am_dmaseg)) != 0) {
- free(mem->am_dmaseg, M_AGP, 0);
- free(mem, M_AGP, 0);
+ free(mem->am_dmaseg, M_AGP, sizeof (*mem->am_dmaseg));
+ free(mem, M_AGP, sizeof *mem);
printf("agp: agp_alloc_dmamem(%d)\n", error);
return (NULL);
}
@@ -670,7 +670,7 @@ agp_i810_alloc_memory(void *softc, int type, vsize_t size)
if ((error = bus_dmamap_create(sc->sc_dmat, size,
size / PAGE_SIZE + 1, size, 0, BUS_DMA_NOWAIT,
&mem->am_dmamap)) != 0) {
- free(mem, M_AGP, 0);
+ free(mem, M_AGP, sizeof *mem);
printf("agp: bus_dmamap_create(%d)\n", error);
return (NULL);
}
@@ -694,14 +694,14 @@ agp_i810_free_memory(void *softc, struct agp_memory *mem)
if (mem->am_type == 2) {
agp_free_dmamem(sc->sc_dmat, mem->am_size, mem->am_dmamap,
mem->am_dmaseg);
- free(mem->am_dmaseg, M_AGP, 0);
+ free(mem->am_dmaseg, M_AGP, sizeof (*mem->am_dmaseg));
} else if (mem->am_type != 1) {
bus_dmamap_destroy(sc->sc_dmat, mem->am_dmamap);
}
sc->sc_allocated -= mem->am_size;
TAILQ_REMOVE(&sc->sc_memory, mem, am_link);
- free(mem, M_AGP, 0);
+ free(mem, M_AGP, sizeof *mem);
return (0);
}