11
11
#include <zephyr/bluetooth/bluetooth.h>
12
12
#include <zephyr/bluetooth/hci.h>
13
13
#include <zephyr/bluetooth/buf.h>
14
+ #include <zephyr/sys/check.h>
14
15
15
16
#include "addr_internal.h"
16
17
#include "hci_core.h"
@@ -1566,6 +1567,12 @@ int bt_le_ext_adv_create(const struct bt_le_adv_param *param,
1566
1567
return - EAGAIN ;
1567
1568
}
1568
1569
1570
+ CHECKIF (out_adv == NULL ) {
1571
+ LOG_DBG ("out_adv is NULL" );
1572
+
1573
+ return - EINVAL ;
1574
+ }
1575
+
1569
1576
if (!valid_adv_ext_param (param )) {
1570
1577
return - EINVAL ;
1571
1578
}
@@ -1591,6 +1598,12 @@ int bt_le_ext_adv_create(const struct bt_le_adv_param *param,
1591
1598
int bt_le_ext_adv_update_param (struct bt_le_ext_adv * adv ,
1592
1599
const struct bt_le_adv_param * param )
1593
1600
{
1601
+ CHECKIF (adv == NULL ) {
1602
+ LOG_DBG ("adv is NULL" );
1603
+
1604
+ return - EINVAL ;
1605
+ }
1606
+
1594
1607
if (!valid_adv_ext_param (param )) {
1595
1608
return - EINVAL ;
1596
1609
}
@@ -1625,6 +1638,12 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
1625
1638
struct bt_conn * conn = NULL ;
1626
1639
int err ;
1627
1640
1641
+ CHECKIF (adv == NULL ) {
1642
+ LOG_DBG ("adv is NULL" );
1643
+
1644
+ return - EINVAL ;
1645
+ }
1646
+
1628
1647
if (atomic_test_bit (adv -> flags , BT_ADV_ENABLED )) {
1629
1648
return - EALREADY ;
1630
1649
}
@@ -1682,6 +1701,12 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
1682
1701
1683
1702
int bt_le_ext_adv_stop (struct bt_le_ext_adv * adv )
1684
1703
{
1704
+ CHECKIF (adv == NULL ) {
1705
+ LOG_DBG ("adv is NULL" );
1706
+
1707
+ return - EINVAL ;
1708
+ }
1709
+
1685
1710
(void )bt_le_lim_adv_cancel_timeout (adv );
1686
1711
1687
1712
atomic_clear_bit (adv -> flags , BT_ADV_PERSIST );
@@ -1712,6 +1737,12 @@ int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv,
1712
1737
{
1713
1738
bool ext_adv , scannable ;
1714
1739
1740
+ CHECKIF (adv == NULL ) {
1741
+ LOG_DBG ("adv is NULL" );
1742
+
1743
+ return - EINVAL ;
1744
+ }
1745
+
1715
1746
ext_adv = atomic_test_bit (adv -> flags , BT_ADV_EXT_ADV );
1716
1747
scannable = atomic_test_bit (adv -> flags , BT_ADV_SCANNABLE );
1717
1748
@@ -1736,6 +1767,12 @@ int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv)
1736
1767
return - ENOTSUP ;
1737
1768
}
1738
1769
1770
+ CHECKIF (adv == NULL ) {
1771
+ LOG_DBG ("adv is NULL" );
1772
+
1773
+ return - EINVAL ;
1774
+ }
1775
+
1739
1776
/* Advertising set should be stopped first */
1740
1777
if (atomic_test_bit (adv -> flags , BT_ADV_ENABLED )) {
1741
1778
return - EINVAL ;
@@ -1815,6 +1852,12 @@ int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv,
1815
1852
return - ENOTSUP ;
1816
1853
}
1817
1854
1855
+ CHECKIF (adv == NULL ) {
1856
+ LOG_DBG ("adv is NULL" );
1857
+
1858
+ return - EINVAL ;
1859
+ }
1860
+
1818
1861
if (atomic_test_bit (adv -> flags , BT_ADV_SCANNABLE )) {
1819
1862
return - EINVAL ;
1820
1863
} else if (atomic_test_bit (adv -> flags , BT_ADV_CONNECTABLE )) {
@@ -1887,6 +1930,12 @@ int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv,
1887
1930
return - ENOTSUP ;
1888
1931
}
1889
1932
1933
+ CHECKIF (adv == NULL ) {
1934
+ LOG_DBG ("adv is NULL" );
1935
+
1936
+ return - EINVAL ;
1937
+ }
1938
+
1890
1939
if (!atomic_test_bit (adv -> flags , BT_PER_ADV_PARAMS_SET )) {
1891
1940
return - EINVAL ;
1892
1941
}
@@ -1922,6 +1971,12 @@ int bt_le_per_adv_set_subevent_data(const struct bt_le_ext_adv *adv, uint8_t num
1922
1971
return - ENOTSUP ;
1923
1972
}
1924
1973
1974
+ CHECKIF (adv == NULL ) {
1975
+ LOG_DBG ("adv is NULL" );
1976
+
1977
+ return - EINVAL ;
1978
+ }
1979
+
1925
1980
for (size_t i = 0 ; i < num_subevents ; i ++ ) {
1926
1981
cmd_length += sizeof (struct bt_hci_cp_le_set_pawr_subevent_data_element );
1927
1982
cmd_length += params [i ].data -> len ;
@@ -1963,6 +2018,12 @@ static int bt_le_per_adv_enable(struct bt_le_ext_adv *adv, bool enable)
1963
2018
return - ENOTSUP ;
1964
2019
}
1965
2020
2021
+ CHECKIF (adv == NULL ) {
2022
+ LOG_DBG ("adv is NULL" );
2023
+
2024
+ return - EINVAL ;
2025
+ }
2026
+
1966
2027
/* TODO: We could setup some default ext adv params if not already set*/
1967
2028
if (!atomic_test_bit (adv -> flags , BT_PER_ADV_PARAMS_SET )) {
1968
2029
return - EINVAL ;
0 commit comments