Skip to content

Commit 0266738

Browse files
committed
BLE: Fix insertion to host resolving list.
1 parent 3a632a3 commit 0266738

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

connectivity/FEATURE_BLE/source/generic/PrivateAddressController.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,34 @@ ble_error_t PrivateAddressController::add_device_to_resolving_list(
164164
peer_irk
165165
);
166166
} else {
167+
// ensure an entry is not added twice
168+
for (auto &entry : _resolving_list) {
169+
if (entry.populated &&
170+
entry.peer_address_type == peer_address_type &&
171+
entry.peer_address == peer_identity_address &&
172+
entry.peer_irk == peer_irk
173+
) {
174+
return BLE_ERROR_NONE;
175+
}
176+
}
177+
178+
bool entry_added = false;
167179
for (auto &entry : _resolving_list) {
168180
if (entry.populated == false) {
169181
entry.peer_address_type = peer_address_type;
170182
entry.peer_address = peer_identity_address;
171183
entry.peer_irk = peer_irk;
172184
entry.populated = true;
173-
return BLE_ERROR_NONE;
185+
entry_added = true;
186+
break;
174187
}
175188
}
176189

190+
if (!entry_added) {
191+
return BLE_ERROR_NO_MEM;
192+
}
193+
194+
177195
// Remove unresolved entries from the resolved list
178196
remove_resolution_entry_from_cache(
179197
[&](resolution_entry_t &entry) {

0 commit comments

Comments
 (0)