Skip to content

Commit 5237c3e

Browse files
committed
Nordic BLE:
Cancel pairing if the device fail to allocate the resources necessary for the pairing operation.
1 parent f0c3f14 commit 5237c3e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/nRF5xPalSecurityManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ ble_error_t nRF5xSecurityManager::send_pairing_response(
300300
) {
301301
pairing_control_block_t* pairing_cb = allocate_pairing_cb(connection);
302302
if (!pairing_cb) {
303+
// not enough memory; try to reject the pairing request instead of
304+
// waiting for timeout.
305+
cancel_pairing(connection, pairing_failure_t::UNSPECIFIED_REASON);
303306
return BLE_ERROR_NO_MEM;
304307
}
305308
pairing_cb->role = PAIRING_RESPONDER;

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ ble_error_t nRF5xSecurityManager::send_pairing_response(
277277
) {
278278
pairing_control_block_t* pairing_cb = allocate_pairing_cb(connection);
279279
if (!pairing_cb) {
280+
// not enough memory; try to reject the pairing request instead of
281+
// waiting for timeout.
282+
cancel_pairing(connection, pairing_failure_t::UNSPECIFIED_REASON);
280283
return BLE_ERROR_NO_MEM;
281284
}
282285
pairing_cb->role = PAIRING_RESPONDER;

0 commit comments

Comments
 (0)