From 05bfaa4736383ceefb7d11fbfcd82330e062c862 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 30 Jun 2025 16:48:09 +0200 Subject: [PATCH 1/2] nimble/gap: Check if conn is present if with asserts disabled BLE_HS_DBG_ASSERT is not enabled by default, and that code is already handling error path. --- nimble/host/src/ble_gap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 64f96bd27d..baa010e0b4 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -2092,6 +2092,9 @@ ble_gap_rx_conn_complete(struct ble_gap_conn_complete *evt, uint8_t instance) /* We verified that there is a free connection when the procedure began. */ conn = ble_hs_conn_alloc(evt->connection_handle); BLE_HS_DBG_ASSERT(conn != NULL); + if (conn == NULL) { + return BLE_HS_ENOMEM; + } conn->bhc_itvl = evt->conn_itvl; conn->bhc_latency = evt->conn_latency; From 5d33954e37b2a378fa04baf6b1ff997a9e7a9c94 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 30 Jun 2025 16:50:29 +0200 Subject: [PATCH 2/2] nimble/host: Check if HCI command buffer was allocated BLE_HS_DBG_ASSERT is not enabled by default, and that code is already handling error path. --- nimble/host/src/ble_hs_hci_cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nimble/host/src/ble_hs_hci_cmd.c b/nimble/host/src/ble_hs_hci_cmd.c index 689cb1765b..9d1ecf9ca2 100644 --- a/nimble/host/src/ble_hs_hci_cmd.c +++ b/nimble/host/src/ble_hs_hci_cmd.c @@ -51,6 +51,9 @@ ble_hs_hci_cmd_send(uint16_t opcode, uint8_t len, const void *cmddata) cmd = ble_transport_alloc_cmd(); BLE_HS_DBG_ASSERT(cmd != NULL); + if (cmd == NULL) { + return BLE_HS_ENOMEM; + } cmd->opcode = htole16(opcode); cmd->length = len;