From 149eec704a13a077efbba9470e7ef8f0ad9b1613 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 12 Mar 2025 18:11:05 +0530 Subject: [PATCH] fix(nimble): Fix incorrect event deinit in gatt caching discovery --- nimble/host/src/ble_gattc_cache_conn.c | 27 ++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/nimble/host/src/ble_gattc_cache_conn.c b/nimble/host/src/ble_gattc_cache_conn.c index 5db4af433..bb0c3c5f9 100644 --- a/nimble/host/src/ble_gattc_cache_conn.c +++ b/nimble/host/src/ble_gattc_cache_conn.c @@ -1451,6 +1451,9 @@ static void ble_gattc_cache_search_all_svcs_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; SLIST_FOREACH(svc, &conn->svcs, next) { @@ -1461,7 +1464,6 @@ static void ble_gattc_cache_search_all_svcs_cb(struct ble_npl_event *ev) status = BLE_HS_EDONE; dcb(conn->conn_handle, ble_gattc_cache_error(status, 0), &svc->svc, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); return; } @@ -1526,6 +1528,9 @@ ble_gattc_cache_conn_search_svc_by_uuid_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; SLIST_FOREACH(svc, &conn->svcs, next) { @@ -1535,7 +1540,7 @@ ble_gattc_cache_conn_search_svc_by_uuid_cb(struct ble_npl_event *ev) } status = BLE_HS_EDONE; dcb(conn_handle, ble_gattc_cache_error(status, 0), &svc->svc, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); + return; } @@ -1584,6 +1589,9 @@ ble_gattc_cache_conn_search_inc_svcs_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; SLIST_FOREACH(svc, &conn->svcs, next) { @@ -1594,7 +1602,7 @@ ble_gattc_cache_conn_search_inc_svcs_cb(struct ble_npl_event *ev) } status = BLE_HS_EDONE; dcb(conn->conn_handle, ble_gattc_cache_error(status, 0), &svc->svc, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); + return; } int @@ -1644,6 +1652,9 @@ ble_gattc_cache_conn_search_all_chrs_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; svc = ble_gattc_cache_conn_svc_find_range(conn, op->start_handle); @@ -1654,7 +1665,6 @@ ble_gattc_cache_conn_search_all_chrs_cb(struct ble_npl_event *ev) status = BLE_HS_EDONE; dcb(conn_handle, ble_gattc_cache_error(status, 0), &chr->chr, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); return; } @@ -1705,6 +1715,9 @@ ble_gattc_cache_conn_search_chrs_by_uuid_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; svc = ble_gattc_cache_conn_svc_find_range(conn, op->start_handle); @@ -1717,7 +1730,6 @@ ble_gattc_cache_conn_search_chrs_by_uuid_cb(struct ble_npl_event *ev) status = BLE_HS_EDONE; dcb(conn_handle, ble_gattc_cache_error(status, 0), &chr->chr, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); return; } @@ -1768,6 +1780,9 @@ ble_gattc_cache_conn_search_all_dscs_cb(struct ble_npl_event *ev) if (conn == NULL) { return; } + + ble_npl_event_deinit(&conn->disc_ev); + op = &conn->pending_op; dcb = op->cb; svc = ble_gattc_cache_conn_svc_find_range(conn, op->start_handle); @@ -1777,7 +1792,7 @@ ble_gattc_cache_conn_search_all_dscs_cb(struct ble_npl_event *ev) } status = BLE_HS_EDONE; dcb(conn_handle, ble_gattc_cache_error(status, 0), chr->chr.val_handle, &dsc->dsc, op->cb_arg); - ble_npl_event_deinit(&conn->disc_ev); + return; }