From faaa8e821a53bbf483f151e996eb4bbb21467b60 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Fri, 19 Jan 2024 14:24:43 +0100 Subject: [PATCH] nimble/iso: Fix missing BIG NULL pointer checks The BIG lookup function returns NULL if BIG has not been found, thus to be safe the return value has to be checked in case functions are called with big_handle value of non-existent BIG. --- nimble/host/src/ble_iso.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nimble/host/src/ble_iso.c b/nimble/host/src/ble_iso.c index 5ca94e59f..5c797836f 100644 --- a/nimble/host/src/ble_iso.c +++ b/nimble/host/src/ble_iso.c @@ -29,6 +29,7 @@ #include "host/ble_iso.h" #include "nimble/hci_common.h" #include "sys/queue.h" +#include "ble_hs_priv.h" #include "ble_hs_hci_priv.h" struct ble_iso_big { @@ -213,6 +214,10 @@ ble_iso_rx_create_big_complete(const struct ble_hci_ev_le_subev_create_big_compl int i; big = ble_iso_big_find_by_handle(ev->big_handle); + if (big == NULL) { + BLE_HS_LOG_ERROR("No BIG with handle=%d\n", ev->big_handle); + return; + } big->num_bis = ev->num_bis; @@ -250,6 +255,10 @@ ble_iso_rx_terminate_big_complete(const struct ble_hci_ev_le_subev_terminate_big struct ble_iso_big *big; big = ble_iso_big_find_by_handle(ev->big_handle); + if (big == NULL) { + BLE_HS_LOG_ERROR("No BIG with handle=%d\n", ev->big_handle); + return; + } event.type = BLE_ISO_EVENT_BIG_TERMINATE_COMPLETE; event.big_terminated.big_handle = ev->big_handle;