diff options
| author | maxv <maxv@NetBSD.org> | 2020-03-14 04:49:33 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2020-03-14 04:49:33 +0000 |
| commit | fcc1fcd68ce13e5a365f1f8345a03188915bf650 (patch) | |
| tree | 0c711b4b0d22e7963467e8dc535f55fd99f8c224 /sys/dev/bluetooth | |
| parent | f9a8aa5cd58691a58f44e7e6e2c29d10172b213a (diff) | |
fix memory leaks
Diffstat (limited to 'sys/dev/bluetooth')
| -rw-r--r-- | sys/dev/bluetooth/btkbd.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/sys/dev/bluetooth/btkbd.c b/sys/dev/bluetooth/btkbd.c index ee0c7098d98..ed929f1ad65 100644 --- a/sys/dev/bluetooth/btkbd.c +++ b/sys/dev/bluetooth/btkbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $ */ +/* $NetBSD: btkbd.c,v 1.19 2020/03/14 04:49:33 maxv Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.19 2020/03/14 04:49:33 maxv Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -281,8 +281,10 @@ btkbd_parse_desc(struct btkbd_softc *sc, int id, const void *desc, int dlen) continue; if (h.flags & HIO_VARIABLE) { - if (h.loc.size != 1) + if (h.loc.size != 1) { + hid_end_parse(d); return ("bad modifier size"); + } /* Single item */ if (imod < MAXMOD) { @@ -290,22 +292,28 @@ btkbd_parse_desc(struct btkbd_softc *sc, int id, const void *desc, int dlen) sc->sc_mods[imod].mask = 1 << imod; sc->sc_mods[imod].key = HID_GET_USAGE(h.usage); imod++; - } else + } else { + hid_end_parse(d); return ("too many modifier keys"); + } } else { /* Array */ - if (h.loc.size != 8) + if (h.loc.size != 8) { + hid_end_parse(d); return ("key code size != 8"); - - if (h.loc.count > MAXKEYCODE) + } + if (h.loc.count > MAXKEYCODE) { + hid_end_parse(d); return ("too many key codes"); - - if (h.loc.pos % 8 != 0) + } + if (h.loc.pos % 8 != 0) { + hid_end_parse(d); return ("key codes not on byte boundary"); - - if (sc->sc_nkeycode != 0) + } + if (sc->sc_nkeycode != 0) { + hid_end_parse(d); return ("multiple key code arrays\n"); - + } sc->sc_keycodeloc = h.loc; sc->sc_nkeycode = h.loc.count; } |
