From 68dba56ac86aa4731c75e65455ebb70ef660cffb Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 9 Mar 2020 10:42:37 +0800 Subject: [PATCH] ble_mesh: Check buf->ref before unref the buffer --- components/bt/esp_ble_mesh/mesh_core/adv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index e4cf567f7..b8601d644 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -329,8 +329,8 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool) struct net_buf *buf = &pool->__bufs[i]; if (buf->ref > 1U) { buf->ref = 1U; - net_buf_unref(buf); } + net_buf_unref(buf); } } @@ -372,6 +372,9 @@ static void bt_mesh_unref_buf(bt_mesh_msg_t *msg) if (msg->arg) { buf = (struct net_buf *)msg->arg; BLE_MESH_ADV(buf)->busy = 0U; + if (buf->ref > 1U) { + buf->ref = 1U; + } net_buf_unref(buf); }