nimble/l2cap: Fix possible memory leak

This commit is contained in:
Łukasz Rymanowski
2019-03-21 12:21:25 +01:00
parent 3ea16d5553
commit cf63688ebf
+6 -4
View File
@@ -393,13 +393,15 @@ ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf *txom)
{
int rc;
struct os_mbuf *om;
txom = ble_l2cap_prepend_hdr(txom, chan->dcid, OS_MBUF_PKTLEN(txom));
if (txom == NULL) {
om = ble_l2cap_prepend_hdr(txom, chan->dcid, OS_MBUF_PKTLEN(txom));
if (om == NULL) {
os_mbuf_free_chain(txom);
return BLE_HS_ENOMEM;
}
rc = ble_hs_hci_acl_tx(conn, &txom);
rc = ble_hs_hci_acl_tx(conn, &om);
switch (rc) {
case 0:
/* Success. */
@@ -407,7 +409,7 @@ ble_l2cap_tx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
case BLE_HS_EAGAIN:
/* Controller could not accommodate full packet. Enqueue remainder. */
STAILQ_INSERT_TAIL(&conn->bhc_tx_q, OS_MBUF_PKTHDR(txom), omp_next);
STAILQ_INSERT_TAIL(&conn->bhc_tx_q, OS_MBUF_PKTHDR(om), omp_next);
return 0;
default: