From bda4b0c67d2cc66254e9d097aa9e499ba21b2dd8 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 16 Oct 2024 02:36:43 +0200 Subject: [PATCH] nimble/host: Clear ATT queue on conn_free We need to free all mbufs enqueued on ATT queue when connection is freed, otherwise we may leak mbufs. --- nimble/host/src/ble_hs_conn.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nimble/host/src/ble_hs_conn.c b/nimble/host/src/ble_hs_conn.c index 57ba16af8..1e83d33de 100644 --- a/nimble/host/src/ble_hs_conn.c +++ b/nimble/host/src/ble_hs_conn.c @@ -255,6 +255,11 @@ ble_hs_conn_free(struct ble_hs_conn *conn) os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp)); } + while ((omp = STAILQ_FIRST(&conn->att_tx_q)) != NULL) { + STAILQ_REMOVE_HEAD(&conn->att_tx_q, omp_next); + os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp)); + } + #if MYNEWT_VAL(BLE_HS_DEBUG) memset(conn, 0xff, sizeof *conn); #endif