From 286a59c8b5cf9cc5a8c14c6c91201f78aedf0534 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 15 Aug 2019 08:37:49 +0300 Subject: [PATCH] Bluetooth: Mesh: Fix reference count imbalance in bt_mesh_net_resend() The commit 1c7b6688045c21f595e12c451c46edf01961e40d tried to fix resending segments to the GATT bearer, however it got the buffer refernce counting wrong. The bt_mesh_net_resend() function doesn't own a reference to the buffer, i.e. it's not responsible for unrefing it. E.g. bt_mesh_adv_send() takes its own reference. What was missing however was the handling of the callbacks. Use the recently introduced send_cb_finalize() helper to make sure they're called. Signed-off-by: Johan Hedberg --- subsys/bluetooth/mesh/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/net.c b/subsys/bluetooth/mesh/net.c index b0851de3b60..b2f2c3d3585 100644 --- a/subsys/bluetooth/mesh/net.c +++ b/subsys/bluetooth/mesh/net.c @@ -783,7 +783,7 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) && bt_mesh_proxy_relay(&buf->b, dst)) { - net_buf_unref(buf); + send_cb_finalize(cb, cb_data); } else { bt_mesh_adv_send(buf, cb, cb_data); }