summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-09-08 11:13:23 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-09-08 11:13:23 +0000
commitcabe82af1b45e7e7798dc4e87efd03936aba0f3f (patch)
tree3c3942ffca58423bfd02799c8868ee940805157e
parent0a781cacb00fa6ece74e451af31d8c8432a8e6f6 (diff)
sizes for free(); checked by semarie
-rw-r--r--sys/dev/wscons/wsdisplay.c19
-rw-r--r--sys/dev/wscons/wsdisplay_compat_usl.c8
-rw-r--r--sys/dev/wsfont/wsfont.c7
3 files changed, 17 insertions, 17 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index d0b2aca5b6e..3169c0aacfd 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.123 2015/05/08 19:17:20 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.124 2015/09/08 11:13:20 deraadt Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -264,7 +264,7 @@ wsscreen_attach(struct wsdisplay_softc *sc, int console, const char *emul,
struct wsscreen_internal *dconf;
struct wsscreen *scr;
- scr = malloc(sizeof(struct wsscreen), M_DEVBUF, M_ZERO | M_NOWAIT);
+ scr = malloc(sizeof(*scr), M_DEVBUF, M_ZERO | M_NOWAIT);
if (!scr)
return (NULL);
@@ -276,8 +276,7 @@ wsscreen_attach(struct wsdisplay_softc *sc, int console, const char *emul,
*/
(void)(*dconf->wsemul->attach)(1, 0, 0, 0, 0, scr, 0);
} else { /* not console */
- dconf = malloc(sizeof(struct wsscreen_internal),
- M_DEVBUF, M_NOWAIT);
+ dconf = malloc(sizeof(*dconf), M_DEVBUF, M_NOWAIT);
if (dconf == NULL)
goto fail;
dconf->emulops = type->textops;
@@ -299,8 +298,8 @@ wsscreen_attach(struct wsdisplay_softc *sc, int console, const char *emul,
fail:
if (dconf != NULL)
- free(dconf, M_DEVBUF, 0);
- free(scr, M_DEVBUF, 0);
+ free(dconf, M_DEVBUF, sizeof(*dconf));
+ free(scr, M_DEVBUF, sizeof(*scr));
return (NULL);
}
@@ -315,8 +314,8 @@ wsscreen_detach(struct wsscreen *scr)
}
(*scr->scr_dconf->wsemul->detach)(scr->scr_dconf->wsemulcookie,
&ccol, &crow);
- free(scr->scr_dconf, M_DEVBUF, 0);
- free(scr, M_DEVBUF, 0);
+ free(scr->scr_dconf, M_DEVBUF, sizeof(*scr->scr_dconf));
+ free(scr, M_DEVBUF, sizeof(*scr));
}
const struct wsscreen_descr *
@@ -1313,14 +1312,14 @@ wsdisplay_cfg_ioctl(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
buf = malloc(fontsz, M_DEVBUF, M_WAITOK);
error = copyin(d->data, buf, fontsz);
if (error) {
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, fontsz);
return (error);
}
d->data = buf;
error =
(*sc->sc_accessops->load_font)(sc->sc_accesscookie, 0, d);
if (error)
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, fontsz);
return (error);
case WSDISPLAYIO_LSFONT:
diff --git a/sys/dev/wscons/wsdisplay_compat_usl.c b/sys/dev/wscons/wsdisplay_compat_usl.c
index 7ab3d2bbd35..c61b4aa817a 100644
--- a/sys/dev/wscons/wsdisplay_compat_usl.c
+++ b/sys/dev/wscons/wsdisplay_compat_usl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay_compat_usl.c,v 1.27 2015/03/14 03:38:50 jsg Exp $ */
+/* $OpenBSD: wsdisplay_compat_usl.c,v 1.28 2015/09/08 11:13:20 deraadt Exp $ */
/* $NetBSD: wsdisplay_compat_usl.c,v 1.12 2000/03/23 07:01:47 thorpej Exp $ */
/*
@@ -100,7 +100,7 @@ usl_sync_init(struct wsscreen *scr, struct usl_syncdata **sdp,
if (acqsig <= 0 || acqsig >= NSIG || relsig <= 0 || relsig >= NSIG ||
frsig <= 0 || frsig >= NSIG)
return (EINVAL);
- sd = malloc(sizeof(struct usl_syncdata), M_DEVBUF, M_NOWAIT);
+ sd = malloc(sizeof(*sd), M_DEVBUF, M_NOWAIT);
if (!sd)
return (ENOMEM);
sd->s_scr = scr;
@@ -114,7 +114,7 @@ usl_sync_init(struct wsscreen *scr, struct usl_syncdata **sdp,
timeout_set(&sd->s_detach_ch, usl_detachtimeout, sd);
res = wsscreen_attach_sync(scr, &usl_syncops, sd);
if (res) {
- free(sd, M_DEVBUF, 0);
+ free(sd, M_DEVBUF, sizeof(*sd));
return (res);
}
*sdp = sd;
@@ -133,7 +133,7 @@ usl_sync_done(struct usl_syncdata *sd)
(*sd->s_callback)(sd->s_cbarg, ENXIO, 0);
}
wsscreen_detach_sync(sd->s_scr);
- free(sd, M_DEVBUF, 0);
+ free(sd, M_DEVBUF, sizeof(*sd));
}
int
diff --git a/sys/dev/wsfont/wsfont.c b/sys/dev/wsfont/wsfont.c
index 65e64f5aff7..67249fbc5ad 100644
--- a/sys/dev/wsfont/wsfont.c
+++ b/sys/dev/wsfont/wsfont.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfont.c,v 1.40 2015/03/14 03:38:50 jsg Exp $ */
+/* $OpenBSD: wsfont.c,v 1.41 2015/09/08 11:13:22 deraadt Exp $ */
/* $NetBSD: wsfont.c,v 1.17 2001/02/07 13:59:24 ad Exp $ */
/*-
@@ -338,8 +338,9 @@ wsfont_rotate_internal(struct wsdisplay_font *font)
* If we seem to have rotated this font already, drop the
* new one...
*/
- free(newbits, M_DEVBUF, 0);
- free(newfont, M_DEVBUF, 0);
+ free(newbits, M_DEVBUF,
+ font->numchars * newstride * font->fontwidth);
+ free(newfont, M_DEVBUF, sizeof *font);
newfont = NULL;
}