From 14aa55b3531f0a1b419c38ca1c74617d1bad1c65 Mon Sep 17 00:00:00 2001 From: "isha.pardikar@espressif.com" Date: Fri, 17 Feb 2023 17:37:00 +0530 Subject: [PATCH] BluFi : Fixed hdr getting free twice Closes IDFGH-9378 --- .../btc/profile/esp/blufi/bluedroid_host/esp_blufi.c | 2 -- .../btc/profile/esp/blufi/nimble_host/esp_blufi.c | 10 +++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c index ea23baee1fe..a0da30f43d5 100644 --- a/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c +++ b/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c @@ -385,8 +385,6 @@ void esp_blufi_send_encap(void *arg) retry: if (blufi_env.is_connected == false) { BTC_TRACE_WARNING("%s ble connection is broken\n", __func__); - osi_free(hdr); - hdr = NULL; return; } if (esp_ble_get_cur_sendable_packets_num(BTC_GATT_GET_CONN_ID(blufi_env.conn_id)) > 0) { diff --git a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c index 95d4c1c5a8d..82c49c8b663 100644 --- a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c +++ b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c @@ -431,9 +431,15 @@ void esp_blufi_send_notify(void *arg) struct pkt_info *pkts = (struct pkt_info *) arg; struct os_mbuf *om; om = ble_hs_mbuf_from_flat(pkts->pkt, pkts->pkt_len); + if (om == NULL) { + ESP_LOGE(TAG, "Error in allocating memory"); + return; + } int rc = 0; rc = ble_gatts_notify_custom(blufi_env.conn_id, gatt_values[1].val_handle, om); - assert(rc == 0); + if (rc != 0) { + ESP_LOGE(TAG, "Error in sending notification"); + } } void esp_blufi_disconnect(void) @@ -448,8 +454,6 @@ void esp_blufi_send_encap(void *arg) struct blufi_hdr *hdr = (struct blufi_hdr *)arg; if (blufi_env.is_connected == false) { BTC_TRACE_WARNING("%s ble connection is broken\n", __func__); - osi_free(hdr); - hdr = NULL; return; } btc_blufi_send_notify((uint8_t *)hdr,