diff --git a/include/zephyr/bluetooth/iso.h b/include/zephyr/bluetooth/iso.h index 782ad7df58b6b3..4251a2c87cb1a4 100644 --- a/include/zephyr/bluetooth/iso.h +++ b/include/zephyr/bluetooth/iso.h @@ -140,6 +140,14 @@ extern "C" { /** Maximum pre-transmission offset */ #define BT_ISO_PTO_MAX 0x0FU +/** + * @brief Check if ISO BIS bitfield is valid (BT_ISO_BIS_INDEX_BIT(1)|..|BT_ISO_BIS_INDEX_BIT(31)) + * + * @param _bis_bitfield BIS index bitfield (uint32) + */ +#define BT_ISO_VALID_BIS_BITFIELD(_bis_bitfield) \ + ((_bis_bitfield) != 0U && (_bis_bitfield) <= BIT_MASK(BT_ISO_BIS_INDEX_MAX)) + /** * @brief Life-span states of ISO channel. Used only by internal APIs dealing with setting channel * to proper state depending on operational context. diff --git a/subsys/bluetooth/host/iso.c b/subsys/bluetooth/host/iso.c index 17e0f3dfb20e6f..806d1a1c89c035 100644 --- a/subsys/bluetooth/host/iso.c +++ b/subsys/bluetooth/host/iso.c @@ -3316,7 +3316,7 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para return -EINVAL; } - CHECKIF(param->bis_bitfield == 0U || param->bis_bitfield > BIT_MASK(BT_ISO_BIS_INDEX_MAX)) { + CHECKIF(param->bis_bitfield == 0U || !BT_ISO_VALID_BIS_BITFIELD(param->bis_bitfield)) { LOG_DBG("Invalid BIS bitfield 0x%08x", param->bis_bitfield); return -EINVAL; }