From ba5cf4956ab506746b23a65923674534aa94553f Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Mon, 6 May 2024 17:56:08 +0530 Subject: [PATCH] nimble/host: Avoid slave instance reset inside extract_cb --- nimble/host/src/ble_gap.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 44d57707ad..cad623ad38 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -1617,6 +1617,18 @@ ble_gap_rx_adv_set_terminated(const struct ble_hci_ev_le_subev_adv_set_terminate ble_gap_adv_finished(ev->adv_handle, reason, conn_handle, ev->num_events); } +static void +ble_gap_slave_get_cb(uint8_t instance, + ble_gap_event_fn **out_cb, void **out_cb_arg) +{ + ble_hs_lock(); + + *out_cb = ble_gap_slave[instance].cb; + *out_cb_arg = ble_gap_slave[instance].cb_arg; + + ble_hs_unlock(); +} + void ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev) { @@ -1624,7 +1636,7 @@ ble_gap_rx_scan_req_rcvd(const struct ble_hci_ev_le_subev_scan_req_rcvd *ev) ble_gap_event_fn *cb; void *cb_arg; - ble_gap_slave_extract_cb(ev->adv_handle, &cb, &cb_arg); + ble_gap_slave_get_cb(ev->adv_handle, &cb, &cb_arg); if (cb != NULL) { memset(&event, 0, sizeof event); event.type = BLE_GAP_EVENT_SCAN_REQ_RCVD;