From 6d0e282513e8ebdc3cf85b7d4005902cffc98fed Mon Sep 17 00:00:00 2001 From: Jin Chen Date: Wed, 3 Dec 2025 11:40:47 +0800 Subject: [PATCH] fix(ble): fix hci log malloc failure crash (cherry picked from commit 734031311ad8554b600718bf8add68836121f72b) Co-authored-by: cjin --- components/bt/common/hci_log/bt_hci_log.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/bt/common/hci_log/bt_hci_log.c b/components/bt/common/hci_log/bt_hci_log.c index fa3de907d6..fef3760b3f 100644 --- a/components/bt/common/hci_log/bt_hci_log.c +++ b/components/bt/common/hci_log/bt_hci_log.c @@ -225,6 +225,10 @@ esp_err_t IRAM_ATTR bt_hci_log_record_data(bt_hci_log_t *p_hci_log_ctl, char *st ts = esp_timer_get_time(); temp_buf = (uint8_t *)malloc(data_len + 8); + if (!temp_buf) { + return ESP_ERR_NO_MEM; + } + memset(temp_buf, 0x0, data_len + 8); memcpy(temp_buf, &ts, 8);