Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/bluetooth fix memory leaks



details:   https://anonhg.NetBSD.org/src/rev/6ca286082d32
branches:  trunk
changeset: 849778:6ca286082d32
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Mar 14 04:49:33 2020 +0000

description:
fix memory leaks

diffstat:

 sys/dev/bluetooth/btkbd.c |  32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diffs (68 lines):

diff -r ff557ba00efb -r 6ca286082d32 sys/dev/bluetooth/btkbd.c
--- a/sys/dev/bluetooth/btkbd.c Sat Mar 14 04:39:15 2020 +0000
+++ b/sys/dev/bluetooth/btkbd.c Sat Mar 14 04:49:33 2020 +0000
@@ -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 @@
                        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 @@
                                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;
                }



Home | Main Index | Thread Index | Old Index