Module Name: src Committed By: maxv Date: Sat Mar 14 04:49:33 UTC 2020
Modified Files: src/sys/dev/bluetooth: btkbd.c Log Message: fix memory leaks To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/bluetooth/btkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.18 src/sys/dev/bluetooth/btkbd.c:1.19 --- src/sys/dev/bluetooth/btkbd.c:1.18 Sun Dec 10 17:03:07 2017 +++ src/sys/dev/bluetooth/btkbd.c Sat Mar 14 04:49:33 2020 @@ -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, 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, 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; }