From 6dbb1aef80b240bedd329de82fe4031a191ed31a Mon Sep 17 00:00:00 2001 From: fcambus Date: Mon, 22 Jan 2018 12:20:54 +0000 Subject: [PATCH] More sizes for free() in wscons(4). OK visa@ --- sys/dev/wscons/wskbd.c | 5 +++-- sys/dev/wscons/wskbdutil.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index 7316b2e60d1..304d5a92057 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbd.c,v 1.88 2018/01/17 16:54:19 fcambus Exp $ */ +/* $OpenBSD: wskbd.c,v 1.89 2018/01/22 12:20:54 fcambus Exp $ */ /* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */ /* @@ -629,7 +629,8 @@ wskbd_detach(struct device *self, int flags) splx(s); } - free(sc->sc_map, M_DEVBUF, 0); + free(sc->sc_map, M_DEVBUF, + sc->sc_maplen * sizeof(struct wscons_keymap)); /* locate the major number */ for (maj = 0; maj < nchrdev; maj++) diff --git a/sys/dev/wscons/wskbdutil.c b/sys/dev/wscons/wskbdutil.c index f1d108fca1d..c2b553186eb 100644 --- a/sys/dev/wscons/wskbdutil.c +++ b/sys/dev/wscons/wskbdutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbdutil.c,v 1.16 2017/09/08 05:36:53 deraadt Exp $ */ +/* $OpenBSD: wskbdutil.c,v 1.17 2018/01/22 12:20:54 fcambus Exp $ */ /* $NetBSD: wskbdutil.c,v 1.7 1999/12/21 11:59:13 drochner Exp $ */ /*- @@ -383,7 +383,8 @@ wskbd_init_keymap(int newlen, struct wscons_keymap **map, int *maplen) if (newlen != *maplen) { if (*maplen > 0) - free(*map, M_DEVBUF, 0); + free(*map, M_DEVBUF, + *maplen * sizeof(struct wscons_keymap)); *maplen = newlen; *map = mallocarray(newlen, sizeof(struct wscons_keymap), M_DEVBUF, M_WAITOK); -- 2.20.1