Skip to content

Commit 8f0ab45

Browse files
anhmolteivindj-nordic
authored andcommitted
lib: peer_manager: fix potential peer invalidate on peer free issue
Fix a potential issue where freeing the data of a bonded peer while another peer is connected will invalidate the bonded peer in the m_connections array. The issue should only be observable with total link count (CONFIG_NRF_SDH_BLE_TOTAL_LINK_COUNT) equal 1. Signed-off-by: Andreas Moltumyr <[email protected]>
1 parent e509403 commit 8f0ab45

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/peer_manager/modules/id_manager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ uint32_t im_peer_free(pm_peer_id_t peer_id)
366366
const int idx = nrf_sdh_ble_idx_get(conn_handle);
367367
const uint32_t ret = pdb_peer_free(peer_id);
368368

369-
if (ret == NRF_SUCCESS && (idx >= 0) && (idx < IM_MAX_CONN_HANDLES)) {
369+
if ((ret == NRF_SUCCESS) && (conn_handle != BLE_CONN_HANDLE_INVALID) && (idx >= 0) &&
370+
(idx < IM_MAX_CONN_HANDLES)) {
370371
m_connections[idx].peer_id = PM_PEER_ID_INVALID;
371372
}
372373
return ret;

0 commit comments

Comments
 (0)