Skip to content

Commit 1cd8339

Browse files
alwa-nordicmbolivar-nordic
authored andcommitted
[nrf fromtree] Bluetooth: ATT: Fix conn parameter to req cb in att_reset
The conn pointer is still valid / not reused at this time and can be used further up the stack as an identifer. This simplifies the API of ATT, and fixes callbacks in GATT that pass on this value directly since their API does not allow conn to be NULL. Fixes #41794 Signed-off-by: Aleksander Wasaznik <[email protected]>
1 parent bb10558 commit 1cd8339

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

doc/releases/release-notes-3.0.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ Changes in this release
4444
Changes in this release
4545
=======================
4646

47-
Removed APIs in this release:
47+
* GATT callbacks ``bt_gatt_..._func_t`` would previously be called with argument
48+
``conn = NULL`` in the event of a disconnect. This was not documented as part
49+
of the API. This behavior is changed so the ``conn`` argument is provided as
50+
normal when a disconnect occurs.
51+
52+
Removed APIs in this release
53+
============================
4854

4955
* The following Kconfig options related to radio front-end modules (FEMs) were
5056
removed:

subsys/bluetooth/host/att.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,8 +2622,6 @@ static void att_reset(struct bt_att *att)
26222622
net_buf_unref(buf);
26232623
}
26242624

2625-
att->conn = NULL;
2626-
26272625
/* Notify pending requests */
26282626
while (!sys_slist_is_empty(&att->reqs)) {
26292627
struct bt_att_req *req;
@@ -2632,13 +2630,17 @@ static void att_reset(struct bt_att *att)
26322630
node = sys_slist_get_not_empty(&att->reqs);
26332631
req = CONTAINER_OF(node, struct bt_att_req, node);
26342632
if (req->func) {
2635-
req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
2633+
req->func(att->conn, BT_ATT_ERR_UNLIKELY, NULL, 0,
26362634
req->user_data);
26372635
}
26382636

26392637
bt_att_req_free(req);
26402638
}
26412639

2640+
/* FIXME: `att->conn` is not reference counted. Consider using `bt_conn_ref`
2641+
* and `bt_conn_unref` to follow convention.
2642+
*/
2643+
att->conn = NULL;
26422644
k_mem_slab_free(&att_slab, (void **)&att);
26432645
}
26442646

0 commit comments

Comments
 (0)