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 more memory leaks by changing the tran...



details:   https://anonhg.NetBSD.org/src/rev/20a2ed31a62f
branches:  trunk
changeset: 337844:20a2ed31a62f
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 30 16:01:51 2015 +0000

description:
Fix more memory leaks by changing the transmit routines to always free the
mbuf to send.

diffstat:

 sys/dev/bluetooth/bcsp.c |  23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diffs (81 lines):

diff -r 8f4ac1059621 -r 20a2ed31a62f sys/dev/bluetooth/bcsp.c
--- a/sys/dev/bluetooth/bcsp.c  Thu Apr 30 15:48:46 2015 +0000
+++ b/sys/dev/bluetooth/bcsp.c  Thu Apr 30 16:01:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $       */
+/*     $NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $       */
 /*
  * Copyright (c) 2007 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1132,12 +1132,12 @@
                pldlen += _m->m_len;
        }
        if (pldlen > 0xfff)
-               return false;
+               goto out;
        if (protocol_id == BCSP_IDENT_ACKPKT || protocol_id > 15)
-               return false;
+               goto out;
 
        if (sc->sc_seq_winspace == 0)
-               return false;
+               goto out;
 
        M_PREPEND(m, sizeof(bcsp_hdr_t), M_DONTWAIT);
        if (m == NULL) {
@@ -1168,12 +1168,15 @@
        _m = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
        if (_m == NULL) {
                aprint_error_dev(sc->sc_dev, "out of memory\n");
-               return false;
+               goto out;
        }
        MBUFQ_ENQUEUE(&sc->sc_seq_retryq, _m);
        bcsp_mux_transmit(sc);
 
        return true;
+out:
+       m_freem(m);
+       return false;
 }
 
 #if 0
@@ -1369,9 +1372,9 @@
        }
        DPRINTFN(1, (" pldlen=%d\n", pldlen));
        if (pldlen > 0xfff)
-               return false;
+               goto out;
        if (protocol_id == BCSP_IDENT_ACKPKT || protocol_id > 15)
-               return false;
+               goto out;
 
        M_PREPEND(m, sizeof(bcsp_hdr_t), M_DONTWAIT);
        if (m == NULL) {
@@ -1397,6 +1400,9 @@
        bcsp_mux_transmit(sc);
 
        return true;
+out:
+       m_freem(m);
+       return false;
 }
 
 #if 0
@@ -1442,7 +1448,6 @@
                m->m_pkthdr.len = m->m_len = 0;
                m_copyback(m, 0, sizeof(sync), sync);
                if (!bcsp_tx_unreliable_pkt(sc, m, BCSP_CHANNEL_LE)) {
-                       m_freem(m);
                        aprint_error_dev(sc->sc_dev,
                            "le-packet transmit failed\n");
                        return EINVAL;



Home | Main Index | Thread Index | Old Index