Module Name: src Committed By: christos Date: Thu Apr 30 16:01:52 UTC 2015
Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: Fix more memory leaks by changing the transmit routines to always free the mbuf to send. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/bluetooth/bcsp.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/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.26 src/sys/dev/bluetooth/bcsp.c:1.27 --- src/sys/dev/bluetooth/bcsp.c:1.26 Mon Apr 27 13:36:41 2015 +++ src/sys/dev/bluetooth/bcsp.c Thu Apr 30 12:01:51 2015 @@ -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 @@ bcsp_tx_reliable_pkt(struct bcsp_softc * 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 @@ bcsp_tx_reliable_pkt(struct bcsp_softc * _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 @@ bcsp_tx_unreliable_pkt(struct bcsp_softc } 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_tx_unreliable_pkt(struct bcsp_softc bcsp_mux_transmit(sc); return true; +out: + m_freem(m); + return false; } #if 0 @@ -1442,7 +1448,6 @@ bcsp_start_le(struct bcsp_softc *sc) 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;