nimble/eatt: Fix NULL deref in ble_eatt_alloc
If ble_eatt_conn_pool was empty we would end up in writing NULL
address.
diff --git a/nimble/host/src/ble_eatt.c b/nimble/host/src/ble_eatt.c
index de1c0d7..f9f7d92 100644
--- a/nimble/host/src/ble_eatt.c
+++ b/nimble/host/src/ble_eatt.c
@@ -177,10 +177,13 @@
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;