Skip to content

Commit 72829b3

Browse files
Thalleyfabiobaltieri
authored andcommitted
Bluetooth: ISO: Added missing NULL checks for API functions
Add missing NULL check for public API function, so that the function will return -EINVAL rather than crashing. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 0b370bc commit 72829b3

File tree

1 file changed

+45
-0
lines changed
  • subsys/bluetooth/host

1 file changed

+45
-0
lines changed

subsys/bluetooth/host/iso.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,11 @@ int bt_iso_cig_create(const struct bt_iso_cig_param *param, struct bt_iso_cig **
20282028
bool advanced = false;
20292029
int i;
20302030

2031+
CHECKIF(param == NULL) {
2032+
LOG_DBG("param is NULL");
2033+
return -EINVAL;
2034+
}
2035+
20312036
CHECKIF(out_cig == NULL) {
20322037
LOG_DBG("out_cig is NULL");
20332038
return -EINVAL;
@@ -2145,6 +2150,11 @@ int bt_iso_cig_reconfigure(struct bt_iso_cig *cig, const struct bt_iso_cig_param
21452150
return -EINVAL;
21462151
}
21472152

2153+
CHECKIF(param == NULL) {
2154+
LOG_DBG("param is NULL");
2155+
return -EINVAL;
2156+
}
2157+
21482158
if (cig->state != BT_ISO_CIG_STATE_CONFIGURED) {
21492159
LOG_DBG("Invalid CIG state: %u", cig->state);
21502160
return -EINVAL;
@@ -2891,6 +2901,21 @@ int bt_iso_big_create(struct bt_le_ext_adv *padv, struct bt_iso_big_create_param
28912901
struct bt_iso_big *big;
28922902
bool advanced = false;
28932903

2904+
CHECKIF(padv == NULL) {
2905+
LOG_DBG("padv is NULL");
2906+
return -EINVAL;
2907+
}
2908+
2909+
CHECKIF(param == NULL) {
2910+
LOG_DBG("param is NULL");
2911+
return -EINVAL;
2912+
}
2913+
2914+
CHECKIF(out_big == NULL) {
2915+
LOG_DBG("out_big is NULL");
2916+
return -EINVAL;
2917+
}
2918+
28942919
if (!atomic_test_bit(padv->flags, BT_PER_ADV_PARAMS_SET)) {
28952920
LOG_DBG("PA params not set; invalid adv object");
28962921
return -EINVAL;
@@ -3077,6 +3102,11 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
30773102
struct bt_iso_chan *bis;
30783103
int err;
30793104

3105+
CHECKIF(big == NULL) {
3106+
LOG_DBG("big is NULL");
3107+
return -EINVAL;
3108+
}
3109+
30803110
if (!atomic_test_bit(big->flags, BT_BIG_INITIALIZED) || !big->num_bis) {
30813111
LOG_DBG("BIG not initialized");
30823112
return -EINVAL;
@@ -3255,6 +3285,21 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para
32553285
struct bt_iso_chan *bis;
32563286
struct bt_iso_big *big;
32573287

3288+
CHECKIF(sync == NULL) {
3289+
LOG_DBG("sync is NULL");
3290+
return -EINVAL;
3291+
}
3292+
3293+
CHECKIF(param == NULL) {
3294+
LOG_DBG("param is NULL");
3295+
return -EINVAL;
3296+
}
3297+
3298+
CHECKIF(out_big == NULL) {
3299+
LOG_DBG("out_big is NULL");
3300+
return -EINVAL;
3301+
}
3302+
32583303
if (!atomic_test_bit(sync->flags, BT_PER_ADV_SYNC_SYNCED)) {
32593304
LOG_DBG("PA sync not synced");
32603305
return -EINVAL;

0 commit comments

Comments
 (0)