Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: ATT: Fix conn parameter to req cb in att_reset
Browse files Browse the repository at this point in the history
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 zephyrproject-rtos#41794

Signed-off-by: Aleksander Wasaznik <[email protected]>
  • Loading branch information
alwa-nordic authored and mbolivar-nordic committed Feb 25, 2022
1 parent bb10558 commit 1cd8339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion doc/releases/release-notes-3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ Changes in this release
Changes in this release
=======================

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

Removed APIs in this release
============================

* The following Kconfig options related to radio front-end modules (FEMs) were
removed:
Expand Down
8 changes: 5 additions & 3 deletions subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -2622,8 +2622,6 @@ static void att_reset(struct bt_att *att)
net_buf_unref(buf);
}

att->conn = NULL;

/* Notify pending requests */
while (!sys_slist_is_empty(&att->reqs)) {
struct bt_att_req *req;
Expand All @@ -2632,13 +2630,17 @@ static void att_reset(struct bt_att *att)
node = sys_slist_get_not_empty(&att->reqs);
req = CONTAINER_OF(node, struct bt_att_req, node);
if (req->func) {
req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
req->func(att->conn, BT_ATT_ERR_UNLIKELY, NULL, 0,
req->user_data);
}

bt_att_req_free(req);
}

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

Expand Down

0 comments on commit 1cd8339

Please sign in to comment.