From 9835888a915e8d4bc6c021f72ba6e76d60aa2dba Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 19 May 2021 14:16:35 +0200 Subject: [PATCH] Bluetooth: controller: Fix data length calculation in adv report Max data length has to be adjusted for subevent code, otherwise we'll hit an assert when trying to add data to event due to insufficient free space. Signed-off-by: Andrzej Kaczmarek --- subsys/bluetooth/controller/hci/hci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 00289cac363..2ec84d38c77 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -5070,8 +5070,9 @@ no_ext_hdr: if (!data_status) { uint8_t data_max_len; - data_max_len = ADV_REPORT_EVT_MAX_LEN - sizeof(*sep) - - sizeof(*adv_info); + data_max_len = ADV_REPORT_EVT_MAX_LEN - + sizeof(struct bt_hci_evt_le_meta_event) - + sizeof(*sep) - sizeof(*adv_info); /* if data cannot fit the event, mark it as incomplete */ if (data_len > data_max_len) { @@ -5408,7 +5409,9 @@ no_ext_hdr: if (!data_status) { uint8_t data_max_len; - data_max_len = ADV_REPORT_EVT_MAX_LEN - sizeof(*sep); + data_max_len = ADV_REPORT_EVT_MAX_LEN - + sizeof(struct bt_hci_evt_le_meta_event) - + sizeof(*sep); /* if data cannot fit the event, mark it as incomplete */ if (data_len > data_max_len) {