nimble/eatt: Fix NULL deref in ble_eatt_alloc

If ble_eatt_conn_pool was empty we would end up in writing NULL
address.
This commit is contained in:
Szymon Janc
2024-03-21 08:52:42 +01:00
parent 1c91062dbc
commit 10c2ae8018
+5 -2
View File
@@ -177,10 +177,13 @@ ble_eatt_alloc(void)
struct ble_eatt *eatt;
eatt = os_memblock_get(&ble_eatt_conn_pool);
if (eatt) {
SLIST_INSERT_HEAD(&g_ble_eatt_list, eatt, next);
if (!eatt) {
BLE_EATT_LOG_WARN("eatt: Failed to allocate new eatt context\n");
return NULL;
}
SLIST_INSERT_HEAD(&g_ble_eatt_list, eatt, next);
eatt->conn_handle = BLE_HS_CONN_HANDLE_NONE;
eatt->chan = NULL;
eatt->client_op = 0;